Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net core 如何使用type=';文本';在blazor服务器端?_Asp.net Core_.net Core_Blazor - Fatal编程技术网

Asp.net core 如何使用type=';文本';在blazor服务器端?

Asp.net core 如何使用type=';文本';在blazor服务器端?,asp.net-core,.net-core,blazor,Asp.net Core,.net Core,Blazor,代码如下: <EditForm OnValidSubmit="@SubmitText" id="inputText"> <InputText @bind-Value="_InputMsgModel.Msg" /> </EditForm> 同时,visual studio现在报告一个错误: 我不能再绑定模型了 我需要将类型设置为text,以便在mobile中正确设置键盘 我怎样才能解决这个问题?谢谢。此代码有什么问题: <Edi

代码如下:

<EditForm OnValidSubmit="@SubmitText" id="inputText">
            <InputText @bind-Value="_InputMsgModel.Msg" />
</EditForm>
同时,visual studio现在报告一个错误:

我不能再绑定模型了

我需要将类型设置为text,以便在mobile中正确设置键盘


我怎样才能解决这个问题?谢谢。

此代码有什么问题:

<EditForm  Model="@_InputMsgModel" OnValidSubmit="@SubmitText" id="inputText" >
    <InputText  @bind-Value="@_InputMsgModel.Msg" />
</EditForm>
你看到文本框中的文本“我的新消息”了吗?我相信你是。。。一切都很好,双向绑定机制运行良好。现在去看看Html…它仍然是
,不能反映文本框的真实状态。想想看

更新:当然,您可以使用以下选项:

<EditForm  Model="@_InputMsgModel" OnValidSubmit="@SubmitText" id="inputText" >
    <input type="text"  @bind-value="@_InputMsgModel.Msg" />
</EditForm>


重要提示:触发错误“属性名称无法…”,因为您在
@bind Value
中使用了大写字母“V”。您应该使用小写:
@bind value
。这是因为您在此处使用输入“Html元素”,并且它具有属性,而不是属性。但是当您使用InputText组件时,
@bind Value
中的大写值引用组件中定义的值属性。

好吧,它可以工作。我还发现了另一种奇怪的方法来实现这一点:
<EditForm  Model="@_InputMsgModel" OnValidSubmit="@SubmitText" id="inputText" >
    <InputText  @bind-Value="@_InputMsgModel.Msg" />
</EditForm>
@code {

InputMsgModel _InputMsgModel = new InputMsgModel();

    private void SubmitText()
    {
        Console.WriteLine(_InputMsgModel.Msg);
    }



    public class InputMsgModel
    {
        public string Msg { get; set; } = "My new message";
    }
}
<EditForm  Model="@_InputMsgModel" OnValidSubmit="@SubmitText" id="inputText" >
    <input type="text"  @bind-value="@_InputMsgModel.Msg" />
</EditForm>