我想在触发提交按钮的同时显示所需的字段警告,如图所示。现在显示消息。是否可以这样做?
C#
<p class="field-wrapper required-field"> <label>Company Name</label><asp:TextBox ID="c_name" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator controltovalidate="c_name" ID="RequiredFieldValidator1" runat="server" ErrorMessage="invalid"></asp:RequiredFieldValidator></p>
答案 0 :(得分:0)
是的,最简单的方法应该是来自Ajax Toolkit的ValidatorCalloutExtender。
<asp:RequiredFieldValidator ID="rqTextBox1" runat="server" ErrorMessage="Enter Data" ControlToValidate="TextBox1" Display="None"></asp:RequiredFieldValidator>
<ajax:ValidatorCalloutExtender ID="rqValidatorCalloutExtender" runat="server" Enabled="True" TargetControlID="rqTextBox1" > </ajax:ValidatorCalloutExtender>
此处的工作示例:http://www.ajaxcontroltoolkit.com/ValidatorCallout/ValidatorCallout.aspx
答案 1 :(得分:0)
使用html输入标记:
<input id="c_name" type="text" name="c_name" placeholder="Company Name" autofocus="autofocus" required="required" />