2010-02-27 43 views
2

我需要幫助才能在更新面板中使用java腳本。 我有複選框,帶有MaskedEditExtender的文本框在Web內容表單的更新面板中。 我想更改MaskedEditExtender的遮罩,當我選中複選框而沒有使用java腳本對更新面板執行回溯操作時,任何人都可以幫助我。使用java腳本更改MaskedEditExtender的蒙版值

這裏是我的代碼:

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"> 

<script src="~/js/jquery-1.4.1.js" type="text/javascript"></script> 
<script type="text/javascript"> 


</script> 
</asp:Content> 
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> 

<p style="height: 1480px; width: 953px"> 
&nbsp;<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="txtMobileHome" runat="server" Style="top: 226px; left: 550px; position: absolute; 
       height: 22px; width: 128px"></asp:TextBox> 
<cc1:MaskedEditExtender ID="txtMobileHome_MaskedEditExtender" runat="server" CultureAMPMPlaceholder="" 
       CultureCurrencySymbolPlaceholder="" CultureDateFormat="" CultureDatePlaceholder="" 
       CultureDecimalPlaceholder="" CultureThousandsPlaceholder="" CultureTimePlaceholder="" 
       Enabled="True" TargetControlID="txtMobileHome" Mask="(999)999-9999"> 
      </cc1:MaskedEditExtender> 
      <asp:RegularExpressionValidator ID="REV_HomeMobile" runat="server" ErrorMessage="Please enter valid Mobile Number " 
       ControlToValidate="txtMobileHome" ValidationExpression="\d{3}\d{3}\d{4}" Style="position: absolute; 
       top: 248px; left: 501px; margin-bottom: 0px; height: 21px;">  
    </asp:RegularExpressionValidator> 

<asp:CheckBox ID="chkIntphoneHome" runat="server" Text="Internation Code" Style="position: absolute; 
       top: 113px; left: 549px;" 
       oncheckedchanged="chkIntphoneHome_CheckedChanged" AutoPostBack="True" 
       /> 

 <asp:AsyncPostBackTrigger ControlID="chkIntMobileHome" 
      EventName="CheckedChanged" /> 



    </Triggers> 
</asp:UpdatePanel> 
</p> 
</asp:Content> 
+0

檢查此示例其關於如何使用java腳本來設置ajax控件屬性。 http://forums.asp.net/p/1472961/3424520.aspx#3424520 – Eyla 2010-03-04 20:07:31

回答

0
<asp:CheckBox ID="chkIntphoneHome" runat="server" Text="Internation Code" Style="position: absolute; 
      top: 113px; left: 549px;" 
      oncheckedchanged="chkIntphoneHome_CheckedChanged" onAutoPostBack="True" onchange="javascript:CallMe()" 
      /> 
    <script> 
    function CallMe() { 
     if (document.getElementById('CheckBox1').checked) { 
      $find("txtMobileHome_MaskedEditExtender").set_Mask("99.9"); 
      $find("txtMobileHome_MaskedEditExtender")._convertMask(); 
      //for checking that mask value has been changed or not 
      alert($find("txtMobileHome_MaskedEditExtender").get_Mask()); 
     } 
     else { 
      $find("txtMobileHome_MaskedEditExtender").set_Mask("99.9999"); 
      $find("txtMobileHome_MaskedEditExtender")._convertMask(); 
      //for checking that mask value has been changed or not 
      alert($find("txtMobileHome_MaskedEditExtender").get_Mask()); 
     } 
    } 
    </script> 

或類似這樣的

<asp:CheckBox ID="chkIntphoneHome" runat="server" Text="Internation Code" Style="position: absolute; 
     top: 113px; left: 549px;" 
     oncheckedchanged="chkIntphoneHome_CheckedChanged" onAutoPostBack="True" onchange="javascript:CallMe()" 
     /> 
    <script> 
    function CallMe() { 
     if (document.getElementById('CheckBox1').checked) { 

      $find("MaskedEditExtender1")._MaskConv = "99.9"; 
      //for checking that mask value has been changed or not 
      alert($find("txtMobileHome_MaskedEditExtender").get_Mask()); 
     } 
     else { 
      $find("MaskedEditExtender1")._MaskConv = "99.9999"; 
     //for checking that mask value has been changed or not 
     alert($find("txtMobileHome_MaskedEditExtender").get_Mask()); 
    } 
}