【发布时间】:2017-03-09 05:06:17
【问题描述】:
我的布局页面中有表单标签。我不能在内容页面中使用表单标签,所以我正在使用 Form method="post" 如何为此创建按钮单击事件以及如何对 html 输入类型进行验证?
<form class="contact-form-title white" method="post">
<label id="lblFirstName" runat="server" title="First Name:">First Name:</label>
<input type="text" id="txtFirstNam" runat="server" /><br />
<label id="lblLastName" runat="server" title="Last Name:">Last Name:</label>
<input type="text" id="txtLastNam" runat="server" /><br />
<label id="lblEmail" runat="server" title="Email ID:">Email ID:</label>
<input type="text" id="txtEmail" runat="server" />
<label id="lblMessage" runat="server" title="Message">Message:</label>
<textarea id="txtMessag" runat="server" ></textarea><br />
<input type="submit" class="btn delicious f-center" runat="server" id="btnContac" name="SUBMIT" onserverclick="btnContac_Click" style="height:25%; width:10%;"/>
</form>
后端:
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnContac_Click(object sender, EventArgs e)
{
string FirstName = txtFirstNam.Value;
string LastName = txtLastNam.Value;
string EmailID = txtEmail.Value;
string Message = txtLastNam.Value;
}
【问题讨论】:
-
我想我不明白...正如我所见,您在单击时会收到回发,并且可以从输入字段中读取值。问题是什么?
-
这是 asp.net 还是 mvc?
-
@AnilKumar asp.net
-
代码不起作用?到达 btnContac_Click 了吗?