UpdatePanel内部的验证控件不起作用 [英] Validation controls inside of UpdatePanel doesn't work
本文介绍了UpdatePanel内部的验证控件不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在更新面板中有一个RegularExpressionValidator,它没有工作它不显示错误消息,如果我删除updatepanel它工作可以任何人帮助我在updatepanel内工作RegularExpressionValidator
< asp:Panel ID = pnlPopup BorderStyle = Solid runat = server >
< asp:UpdatePanel ID = UpdatePanel1 runat = server UpdateMode = 有条件的 >
< ContentTemplate>
< div style = background-color:GrayText; < span class =code-keyword>>
< table border = 0 >
< tr>
< td colspan = 3 style = background-color:Maroon; color:White; font-weight:bold > 时间表输入< / td >
< / tr >
< tr>
< td>< asp:标签ID = lblEtyID Text = EntryID runat = server Visible = False > < / asp:Label > < / td >
< td>< asp:TextBox ID = txtEtyID runat = server已启用= False Visible = False
Width = 400px > < / asp:TextBox > < / td < span class =code-keyword>>
< / tr >
< tr>
< td> < asp:Label ID = lbluserid Text = UserID runat = server Visible = False > < / asp:标签 > < / td >
< td>< asp:TextBox ID = txtUserID runat = < span class =code-string> server已启用= False Visible = False
Width = 402px > < / asp:TextBox > < / td >
< / tr >
< tr>
< td>< asp:标签ID = lbltypeid Text = 输入 runat = server > < / asp:Label > < / td >
< td>< asp:DropDownList ID = ddlTypeid runat = server 宽度= 408px AutoPostBack = true
DataTextField = ItemName AppendDataBoundItems = true onselectedindexchanged = ddlTypeid_SelectedIndexChanged >
< asp:listitem selected = True text = - 选择 - value = > < / asp:listitem >
< / asp:DropDownList > < / td >
< / tr >
< div id = divTypedevelopment runat = server >
< tr>
< td>< asp:标签ID = lblProID Text = ProductName runat = server > < / asp:Label > < / td >
< td>< asp:DropDownList ID = ddlproductid runat = server AutoPostBack = true
AppendDataBoundItems = true onselectedindexchanged = ddlproductid_SelectedIndexChanged Width = 406px >
< asp:listitem selected = True text = - 选择 - value = > < / asp:listitem >
< / < span class =code-leadattribute> asp:DropDownList > < / < span class =code-leadattribute> td >
< td>< asp:标签ID = Label5 runat = server Text = * style = 颜色:红色 > < / asp:标签 > < / td >
< / tr >
< tr>
< td>< asp:标签ID = lblverid Text = VersionNumber runat = server > < / asp:Label > < / td >
< td>< asp:DropDownList ID = ddlversionid runat = server 宽度= 408px >
< asp:listitem selected = True text = - 选择 - value = > < / asp:listitem >
< / asp: DropDownList > < / td >
< td>< asp:标签ID = < span class =code-string> lblmand runat = server Text = * style = 颜色:红色 > < ; / asp:标签 > < ; / td >
< / tr >
< tr>
< td class = style2 >< asp:标签ID = lblbug Text = BugID runat = server > < / asp:标签 > < / td >
< td class = style2>< asp:TextBox ID = txtBugid runat = ser ver Width = 30% > < / asp:TextBox >
< asp:RequiredFieldValidator runat = server ControlToValidate = txtBugid ErrorMessage = RequiredFieldValidator > < / asp:RequiredFieldValidator > < / td >
< td class = style2>< asp:Label ID = Label1 runat = server Text = * style = 颜色:红色 > < / asp :标签 >
<% - < asp:RegularExpressionValidator ID = RegularExpressionValidator1 runat = server
ControlToValidate = txtBugid ValidationGroup = 首先 ErrorMessage = 仅输入数字 > < / asp:RegularExpressionValidator > - %>
< / td >
< / tr >
< / div >
< div id = divTypesupport runat = server >
< tr>
< td>< asp:标签ID = lblsuppid Text = SupportID runat = server > < / asp:Label > < / td >
< td>< asp:TextBox ID = txtSupportid runat = server > < / asp: TextBox > < / td >
< td>< asp:Label ID = Label2 runat = server Text = * style = 颜色:红色 > < / asp:标签 >
< % - < asp:RegularExpressionValidator ID = RegularExpressionValidator2 runat = server
ControlToValidate = txtSupportid Vali dationGroup = 首先 ErrorMessage = 仅输入数字 > < / asp:RegularExpressionValidator > - %>
< / td > ;
< / tr >
< / div >
< div id = divTypedescription runat = server >
< tr>
< td>< asp:标签ID = lblDescription Text = 描述 runat = server > < / asp:Label > < / td >
< td>< asp:TextBox ID = txtDescription runat = server > < / asp: TextBox > < / td >
< td>< asp:标签ID = Label3 runat = < span class =code-string> server Text = * style = 颜色:红色 > < span class =code-keyword>< / asp:标签 > < span class =code-keyword>< / td >
< / tr >
< / div >
< tr>
< td>< asp:标签ID = lbldate Text = 日期 runat = server > < / asp:Label > < / td >
< td>< asp:TextBox ID = txtDate runat = server 已启用= 错误 > < / asp:TextBox > < / td >
< td> < / td >
< / tr >
< tr>
< td>< asp:标签ID = lbleffort Text = Effort runat = server > < / asp:Label > < / td >
< td>< asp:TextBox ID = txtEffort runat = server 宽度= 30% > ; < / asp:TextBox >
< asp:RegularExpressionValidator ID = RegularExpressionValidator3 runat = server
ControlToValidate = txtEffort ValidationExpression = ^ [0-9] * $ ErrorMessage = 仅输入数字 EnableViewState = true> < / asp:RegularExpressionValidator > < / td >
< td><% - < asp:标签ID = Label4 runat = server Text = < span class =code-string> * in Hrs style = color:Red > < / asp:Label > - %>
< / td >
< / tr >
< tr >
< td>< asp:Button ID = btnSubmit Text = SUBMIT runat = server
onclick = btnSubmit_Click /> < / td >
< TD> < asp:Button ID = btnCancel Text = CANCEL runat = server
onclick = btnCancel_Click CausesValidation = false /> < / td >
< td> < / td >
<% - < asp:ValidationSummary ID = ValidationSummary ShowSummary = < span class =code-string> False ValidationGroup = 首先 ShowMessageBox = True runat = server /> - %>
< / tr >
< tr>
< td colspan = 2>< asp:Label ID = < span class =code-string> lblInsinfo runat = server ForeColor = #FF3300 > < / asp:标签 > < / td >
< / tr >
< / table < span class =code-keyword>>
< / div >
< / ContentTemplate >
< / / span> asp:UpdatePanel >
<% - < asp:UpdateProgress ID = UpdateProgress1 runat = < span class =code-string> server AssociatedUpdatePanelID = UpdatePanel1
DisplayAfter = 0 DynamicLayout = true >
< ProgressTemplate>
< div id = ProgressBar class=\"ajax-loading\"> ;
Working on your request...</div>
</ProgressTemplate >
</asp:UpdateProgress >--%>
</asp:Panel>
$ p$p> 解决方案 \" ErrorMessage=\"Enter only Numbers\" EnableViewState=true> </asp:RegularExpressionValidator></td>
<td><%--<asp:Label ID=\"Label4\" runat=\"server\" Text=\"* in Hrs\" style=\"color:Red\"></asp:Label>--%>
</td >
</tr>
<tr >
<td ><asp:Button ID=\"btnSubmit\" Text=\"SUBMIT\" runat=\"server\"
onclick=\"btnSubmit_Click\" /></td>
<td> <asp:Button ID=\"btnCancel\" Text=\"CANCEL\" runat=\"server\"
onclick=\"btnCancel_Click\" CausesValidation=\"false\"/></td>
<td></td>
<%--<asp:ValidationSummary ID=\"ValidationSummary\" ShowSummary=\"False\" ValidationGroup=\"First\" ShowMessageBox=\"True\" runat=\"server\" />--%>
</tr>
<tr>
<td colspan=\"2\"><asp:Label ID=\"lblInsinfo\" runat=\"server\" ForeColor=\"#FF3300\"></asp:Label> </td>
</tr>
</table>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<%--<asp:UpdateProgress ID=\"UpdateProgress1\" runat=\"server\" AssociatedUpdatePanelID=\"UpdatePanel1\"
DisplayAfter=\"0\" DynamicLayout=\"true\">
<ProgressTemplate>
<div id=\"ProgressBar\" class=\"ajax-loading\">
Working on your request...</div>
</ProgressTemplate>
</asp:UpdateProgress>--%>
</asp:Panel>
Check whe ther you have added<asp:scriptmanager id=\"ScriptManager1\" runat=\"server\" />
And also removeUpdateMode=\"Conditional\"from the UpdatePanel.
Here is the complete guide about UpdatePanel:
http://www.asp.net/ajax/documentation/live/overview/updatepaneloverview.aspx[^]
I hope this will help to you.
I had a RegularExpressionValidator inside the update panel which not working it dosen't show the error message if i remove updatepanel it works can any one helps me to work the RegularExpressionValidator inside the updatepanel
<asp:Panel ID="pnlPopup" BorderStyle="Solid" runat="server" >
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div style="background-color:GrayText;">
<table border="0">
<tr>
<td colspan="3" style="background-color:Maroon;color:White;font-weight:bold" > Time Sheet Entry </td>
</tr>
<tr>
<td><asp:Label ID="lblEtyID" Text="EntryID" runat="server" Visible="False"></asp:Label></td>
<td><asp:TextBox ID="txtEtyID" runat="server" Enabled="False" Visible="False"
Width="400px"></asp:TextBox></td>
</tr>
<tr>
<td> <asp:Label ID="lbluserid" Text="UserID" runat="server" Visible="False"></asp:Label></td>
<td><asp:TextBox ID="txtUserID" runat="server" Enabled="False" Visible="False"
Width="402px"></asp:TextBox></td>
</tr>
<tr>
<td><asp:Label ID="lbltypeid" Text="Type" runat="server"></asp:Label></td>
<td><asp:DropDownList ID="ddlTypeid" runat="server" Width="408px" AutoPostBack="true"
DataTextField="ItemName" AppendDataBoundItems ="true" onselectedindexchanged="ddlTypeid_SelectedIndexChanged">
<asp:listitem selected="True" text="--Select--" value=""></asp:listitem>
</asp:DropDownList> </td>
</tr>
<div id="divTypedevelopment" runat="server">
<tr>
<td><asp:Label ID="lblProID" Text="ProductName" runat="server"></asp:Label></td>
<td><asp:DropDownList ID="ddlproductid" runat="server" AutoPostBack="true"
AppendDataBoundItems ="true" onselectedindexchanged="ddlproductid_SelectedIndexChanged" Width="406px">
<asp:listitem selected="True" text="--Select--" value=""></asp:listitem>
</asp:DropDownList></td>
<td><asp:Label ID="Label5" runat="server" Text="*" style="color:Red"></asp:Label></td>
</tr>
<tr>
<td><asp:Label ID="lblverid" Text="VersionNumber" runat="server"></asp:Label></td>
<td><asp:DropDownList ID="ddlversionid" runat="server" Width="408px">
<asp:listitem selected="True" text="--Select--" value=""></asp:listitem>
</asp:DropDownList></td>
<td><asp:Label ID="lblmand" runat="server" Text="*" style="color:Red"></asp:Label></td>
</tr>
<tr>
<td class="style2"><asp:Label ID="lblbug" Text="BugID" runat="server"></asp:Label></td>
<td class="style2"><asp:TextBox ID="txtBugid" runat="server" Width="30%"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="txtBugid" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator></td>
<td class="style2"><asp:Label ID="Label1" runat="server" Text="*" style="color:Red"></asp:Label>
<%--<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="txtBugid" ValidationGroup="First" ErrorMessage="Enter only Numbers" > </asp:RegularExpressionValidator>--%>
</td>
</tr>
</div>
<div id="divTypesupport" runat="server">
<tr>
<td><asp:Label ID="lblsuppid" Text="SupportID" runat="server"></asp:Label></td>
<td><asp:TextBox ID="txtSupportid" runat="server"></asp:TextBox> </td>
<td><asp:Label ID="Label2" runat="server" Text="*" style="color:Red"></asp:Label>
<%--<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server"
ControlToValidate="txtSupportid" ValidationGroup="First" ErrorMessage="Enter only Numbers"></asp:RegularExpressionValidator>--%>
</td>
</tr>
</div>
<div id="divTypedescription" runat="server">
<tr>
<td><asp:Label ID="lblDescription" Text="Description" runat="server"></asp:Label></td>
<td><asp:TextBox ID="txtDescription" runat="server"></asp:TextBox></td>
<td><asp:Label ID="Label3" runat="server" Text="*" style="color:Red"></asp:Label></td>
</tr>
</div>
<tr>
<td><asp:Label ID="lbldate" Text="Date" runat="server"></asp:Label></td>
<td><asp:TextBox ID="txtDate" runat="server" Enabled="False"></asp:TextBox></td>
<td></td>
</tr>
<tr>
<td><asp:Label ID="lbleffort" Text="Effort" runat="server"></asp:Label></td>
<td><asp:TextBox ID="txtEffort" runat="server" Width="30%"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server"
ControlToValidate="txtEffort" ValidationExpression="^[0-9]*$" ErrorMessage="Enter only Numbers" EnableViewState=true> </asp:RegularExpressionValidator></td>
<td><%--<asp:Label ID="Label4" runat="server" Text="* in Hrs" style="color:Red"></asp:Label>--%>
</td>
</tr>
<tr >
<td ><asp:Button ID="btnSubmit" Text="SUBMIT" runat="server"
onclick="btnSubmit_Click" /></td>
<td> <asp:Button ID="btnCancel" Text="CANCEL" runat="server"
onclick="btnCancel_Click" CausesValidation="false"/></td>
<td></td>
<%--<asp:ValidationSummary ID="ValidationSummary" ShowSummary="False" ValidationGroup="First" ShowMessageBox="True" runat="server" />--%>
</tr>
<tr>
<td colspan="2"><asp:Label ID="lblInsinfo" runat="server" ForeColor="#FF3300"></asp:Label> </td>
</tr>
</table>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<%--<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1"
DisplayAfter="0" DynamicLayout="true">
<ProgressTemplate>
<div id="ProgressBar" class="ajax-loading">
Working on your request...</div>
</ProgressTemplate>
</asp:UpdateProgress>--%>
</asp:Panel>
解决方案
" ErrorMessage="Enter only Numbers" EnableViewState=true> </asp:RegularExpressionValidator></td> <td><%--<asp:Label ID="Label4" runat="server" Text="* in Hrs" style="color:Red"></asp:Label>--%> </td> </tr> <tr > <td ><asp:Button ID="btnSubmit" Text="SUBMIT" runat="server" onclick="btnSubmit_Click" /></td> <td> <asp:Button ID="btnCancel" Text="CANCEL" runat="server" onclick="btnCancel_Click" CausesValidation="false"/></td> <td></td> <%--<asp:ValidationSummary ID="ValidationSummary" ShowSummary="False" ValidationGroup="First" ShowMessageBox="True" runat="server" />--%> </tr> <tr> <td colspan="2"><asp:Label ID="lblInsinfo" runat="server" ForeColor="#FF3300"></asp:Label> </td> </tr> </table> </div> </ContentTemplate> </asp:UpdatePanel> <%--<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1" DisplayAfter="0" DynamicLayout="true"> <ProgressTemplate> <div id="ProgressBar" class="ajax-loading"> Working on your request...</div> </ProgressTemplate> </asp:UpdateProgress>--%> </asp:Panel>
Check whether you have added<asp:scriptmanager id="ScriptManager1" runat="server" />
And also removeUpdateMode="Conditional"from the UpdatePanel.
Here is the complete guide about UpdatePanel:
http://www.asp.net/ajax/documentation/live/overview/updatepaneloverview.aspx[^]
I hope this will help to you.
这篇关于UpdatePanel内部的验证控件不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文