复选框内没有响应更新面板C#

时间:2010-02-24 07:23:21

标签: c# asp.net-ajax checkbox updatepanel

我有一个复选框,RequiredFieldValidator和带有editmask扩展程序的文本框

我想在检查复选框时以编程方式更改控件属性,但是当我检查它时没有发生任何问题。 我把控制回发了,我添加了触发器。 当放置断点并逐步使用代码时,将通过代码但没有任何改变。

请查看我的代码并告诉我如何解决这个问题 谢谢,

 <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>

代码背后: .................................

    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";


        }

2 个答案:

答案 0 :(得分:0)

尝试从复选框中删除EnableViewstate =“false”。此外,页面本身是偶然禁用viewstate吗?

答案 1 :(得分:0)

这一行的问题:   txtHomePhone_MaskedEditExtender.Mask =“”;

我没有MaskedEditExtender的空面具。

谢谢