C# 如何在c代码中提交html输入?
我想在asp.net代码中使用一些HTML输入字段(即代码隐藏代码-C#) 这是我的代码:C# 如何在c代码中提交html输入?,c#,html,asp.net,C#,Html,Asp.net,我想在asp.net代码中使用一些HTML输入字段(即代码隐藏代码-C#) 这是我的代码: <form id="contact_form" runat="server"> <div> <label for="name" >Name</label> <input id="name" type="text" /> <span id="nameinfo">what's y
<form id="contact_form" runat="server">
<div>
<label for="name" >Name</label>
<input id="name" type="text" />
<span id="nameinfo">what's your name?</span>
</div>
<div>
名称
你叫什么名字?
将id用作.cs文件中的名称
添加
runat=“服务器”
在您的HTML输入中,例如:
<input type="text" id="input1" runat="server" value="" />
解决方案1:
向输入中添加一个名称,如下所示:
<input id="name" type="text" name="name" />
<asp:TextBox id="tbName" runat="server" />
解决方案2:
如果您使用的是Web表单,请将输入替换为asp:TextBox控件,如下所示:
<input id="name" type="text" name="name" />
<asp:TextBox id="tbName" runat="server" />
这不是一个具体的问题。有很多关于如何使用c#提交和处理html表单数据的教程。
string name = tbName.Text;