Checkbox not responding inside update panel C#
I have a check box, RequiredFieldValidator and textbox that have editmask extender
I want to change the control properties programmatically when I check the check box but the problem that nothing happened when I check it. I made the control post back and I added triggers. when put break point and go with code step by step will go through the code but nothing change.
Please see my code and advice me how to solve this problem Thank you,
<asp:UpdatePanel ID="UPanelContacts" runat="server">
<ContentTemplate>
<asp:Panel ID="PContactsInfo" runat="server" GroupingText="Personal Information"
BorderStyle="Dotted" Style="position: absolute; top: 103px; left: 221px; height: 468px;
width: 811px; margin-top: 69px;">
<asp:TextBox ID="txtHomePhone" runat="server" Style="top: 147px; left: 543px; position: absolute;
height: 22px; width: 128px" AutoPostBack="True" ></asp:TextBox>
<cc1:MaskedEditExtender ID="txtHomePhone_MaskedEditExtender" runat="server" CultureAMPMPlaceholder=""
CultureCurrencySymbolPlaceholder="" CultureDateFormat="" CultureDatePlaceholder=""
CultureDecimalPlaceholder="" CultureThousandsPlaceholder="" CultureTimePlaceholder=""
Enabled="True" Mask="(999)999-9999" TargetControlID="txtHomePhone"
AutoComplete="False">
</cc1:MaskedEditExtender>
<asp:RegularExpressionValidator ID="REV_HomePhone" runat="server" ErrorMessage="Please enter valid Home Phone"
Style="position: absolute; top: 177px; left: 476px; width: 226px;"
Display="Dynamic" ControlToValidate="txtHomePhone"
ValidationExpression="\d{3}?\d{3}\d{4}"></asp:RegularExpressionValidator>
<asp:CheckBox ID="chkIntphoneHome" runat="server" Text="Internation Code" Style="position: absolute;
top: 113px; left: 549px;" AutoPostBack="True" EnableViewState="False" oncheckedchanged="chkIntphoneHome_CheckedChanged"
/>
</asp:Panel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="chkIntphoneHome"
EventName="CheckedChanged" />
</Triggers>
</asp:UpdatePanel>
Code behind: .................................
开发者_StackOverflow社区 protected void chkIntphoneHome_CheckedChanged(object sender, EventArgs e)
{
if (chkIntphoneHome.Checked == true)
{
txtHomePhone.Enabled = true;
txtHomePhone.Text = "";
txtHomePhone_MaskedEditExtender.Mask = "";
txtHomePhone.MaxLength = 12;
//REV_HomePhone.ValidationExpression = @"\d{9}|d{10}|d{11}|d{12}";
REV_HomePhone.ErrorMessage = "Please enter at less 9 numbers";
}
else
{
txtHomePhone.Text = "";
REV_HomePhone.ValidationExpression = @"\d{3}?\d{3}\d{4}";
REV_HomePhone.ErrorMessage="Please enter valid Home Phone";
txtHomePhone_MaskedEditExtender.Mask = "(999)999-9999";
}
Try removing the EnableViewstate="false" from your checkbox. Also, is viewstate by chance disabled on the page itself?
The problem from this line: txtHomePhone_MaskedEditExtender.Mask = "";
I can not have empty mask with MaskedEditExtender.
Thank you
精彩评论