我在下表中有4个验证码,当我刷新它时,所有验证码都会刷新,尽管我在所有验证码上分别应用了updatepanel。我可以不使用更新面板分别处理多个控件吗?
<table class="style4">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<tr>
<td colspan="3" class="style21">
<asp:Image ID="Image1" runat="server" Height="174px" ImageUrl="~/Registration/images/registerwithus.jpg"
Width="605px" />
</td>
</tr>
<tr>
<td class="style5">
User Name
</td>
<td colspan="2">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1"
ErrorMessage="Please Enter the correct Name" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style5">
Choose Password
</td>
<td colspan="2">
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TextBox2"
ErrorMessage="Choose Password" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style5">
Confirm Password
</td>
<td class="style6" colspan="2">
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="TextBox3"
Display="Dynamic" ErrorMessage="Choose Password" ForeColor="Red"></asp:RequiredFieldValidator>
<asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="TextBox2"
ControlToValidate="TextBox3" Display="Dynamic" ErrorMessage="Both the Password fields do not match"
ForeColor="#CC0000" SetFocusOnError="True"></asp:CompareValidator>
</td>
</tr>
<tr>
<td class="style5">
Email Id
</td>
<td class="style6" colspan="2">
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="TextBox4"
Display="Dynamic" ErrorMessage="Enter your EmailId" ForeColor="Red"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBox4"
Display="Dynamic" ErrorMessage="Invalid Email Id" ForeColor="Red" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td>
Mob No
</td>
<td colspan="2">
<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ErrorMessage="Invalid Mobile No."
ControlToValidate="TextBox5" ForeColor="Red" ValidationExpression="^[7-9][0-9]{9}$"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td class="style5" rowspan="2">
Captcha
</td>
<td class="style18">
<asp:Label ID="Label2" runat="server" Text="1"></asp:Label>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<cc1:CaptchaControl ID="Captcha1" runat="server" CaptchaBackgroundNoise="Low" CaptchaLength="5"
CaptchaHeight="60" CaptchaWidth="200" CaptchaMinTimeout="5" CaptchaMaxTimeout="240"
FontColor="#D20B0C" NoiseColor="#B1B1B1" Height="40px" Width="199px" CaptchaChars="abcdefghijklmnopqrstuvwxyz" />
<asp:ImageButton ID="ImageButton10" runat="server" ImageUrl="~/Registration/images/loading.jpg"
OnClick="ImageButton1_Click" Style="z-index: 1; left: 394px; top: 463px; position: absolute;
height: 36px; width: 39px" />
</ContentTemplate>
</asp:UpdatePanel>
</td>
<td class="style8">
<asp:Label ID="Label3" runat="server" Text="2"></asp:Label>
<asp:UpdatePanel ID="UpdatePanel3" runat="server">
<ContentTemplate>
<cc1:CaptchaControl ID="Captcha2" runat="server" CaptchaBackgroundNoise="Low" CaptchaLength="5"
CaptchaHeight="60" CaptchaWidth="200" CaptchaMinTimeout="5" CaptchaMaxTimeout="240"
FontColor="#D20B0C" NoiseColor="#B1B1B1" Height="40px" Width="199px" CaptchaChars="123467890" />
<asp:ImageButton ID="ImageButton3" runat="server" ImageUrl="~/Registration/images/loading.jpg"
OnClick="ImageButton3_Click" Style="z-index: 1; left: 724px; top: 465px; position: absolute;
width: 39px; height: 35px" />
</ContentTemplate>
</asp:UpdatePanel>
<br />
</td>
</tr>
<tr>
<td class="style19">
<asp:Label ID="Label4" runat="server" Text="3"></asp:Label>
<asp:UpdatePanel ID="UpdatePanel4" runat="server">
<ContentTemplate>
<cc1:CaptchaControl ID="Captcha3" runat="server" CaptchaBackgroundNoise="Low" CaptchaLength="5"
CaptchaHeight="60" CaptchaWidth="200" CaptchaMinTimeout="5" CaptchaMaxTimeout="240"
FontColor="#D20B0C" NoiseColor="#B1B1B1" Height="40px" Width="199px" />
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/Registration/images/loading.jpg"
OnClick="ImageButton1_Click" Style="z-index: 1; left: 395px; top: 541px; position: absolute;
height: 36px; width: 39px" />
</ContentTemplate>
</asp:UpdatePanel>
</td>
<td class="style11">
<asp:Label ID="Label5" runat="server" Text="4"></asp:Label>
<asp:UpdatePanel ID="UpdatePanel5" runat="server">
<ContentTemplate>
<cc1:CaptchaControl ID="Captcha4" runat="server" CaptchaBackgroundNoise="Low" CaptchaLength="5"
CaptchaHeight="60" CaptchaWidth="200" CaptchaMinTimeout="5" CaptchaMaxTimeout="240"
FontColor="#D20B0C" NoiseColor="#B1B1B1" Height="40px" Width="199px" CaptchaChars="abcdefghijklmnopqrstzxACDEFGHJKLNPQRTUVXYZ2346789" />
<asp:ImageButton ID="ImageButton5" runat="server" ImageUrl="~/Registration/images/loading.jpg"
OnClick="ImageButton5_Click" Style="z-index: 1; left: 728px; top: 540px; position: absolute;
width: 39px; height: 36px" />
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
<tr>
<td class="style14" rowspan="2">
<p class="style17">
Enter Captcha Number</p>
</td>
<td colspan="2" class="style16">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="TextBox6" runat="server"></asp:TextBox>
<asp:Button ID="Button2" runat="server" Style="z-index: 1; left: 357px; top: 597px;
position: absolute; width: 120px; right: 818px" Text="ok" OnClick="Button2_Click" />
<asp:TextBox ID="TextBox7" runat="server" Style="z-index: 1; left: 170px; top: 668px;
position: absolute; height: 31px; width: 165px"></asp:TextBox>
<asp:CustomValidator ID="CustomValidator1" ErrorMessage="Invalid. Please try again."
OnServerValidate="ValidateCaptcha" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
<tr>
<td colspan="2" class="style20">
</td>
</tr>
<tr>
<td class="style5">
<asp:Button ID="Button1" runat="server" Text="Register" OnClick="Button1_Click" BackColor="Black"
BorderStyle="Inset" ForeColor="White" Width="134px" Height="32px" />
</td>
<td colspan="2">
<asp:Label ID="Label1" runat="server"></asp:Label>
</td>
</tr>
</table>
答案 0 :(得分:1)
尝试将UpdateMode="Conditional"
添加到您的所有UpdatePanel,例如
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
这种方式当孩子控制触发部分回发时 - 只有面板本身会受到影响。