2012-03-17 63 views
0

請考慮下面的代碼:文本框沒有得到它從代碼值後面的回傳後

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> 
    <ContentTemplate> 
     <table border="1" cellpadding="8" cellspacing="0" width="700px" style="background-color: Aqua"> 
      <tr> 
       <td style="direction: rtl"> 
        &nbsp; 
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 
       </td> 
       <td style="direction: ltr"> 
        F1 
       </td> 
      </tr> 
      <tr> 
       <td style="direction: rtl"> 
        <asp:DropDownList ID="Drp_1" runat="server" ClientIDMode="Static"> 
         <asp:ListItem Value="1">Head of household</asp:ListItem> 
         <asp:ListItem Value="2">Spouse</asp:ListItem> 
         <asp:ListItem Value="3">Child</asp:ListItem> 
        </asp:DropDownList> 
       </td> 
       <td> 
        F2 
       </td> 
      </tr> 
      <tr> 
       <td style="direction: rtl"> 
        <asp:RadioButtonList ID="Rad_7" runat="server" ClientIDMode="Static"> 
         <asp:ListItem Text="1" Value="1"></asp:ListItem> 
         <asp:ListItem Text="2" Value="2"></asp:ListItem> 
         <asp:ListItem Text="3" Value="3"></asp:ListItem> 
         <asp:ListItem Text="4" Value="4"></asp:ListItem> 
        </asp:RadioButtonList> 
       </td> 
       <td> 
        F3 
       </td> 
      </tr> 
      <tr> 
       <td> 
        <asp:Button ID="BindAgain" runat="server" Height="44px" Text="Submit" ClientIDMode="Static" 
         Width="207px" OnClick="BindAgain_Click" /> 
       </td> 
       <td> 
        <asp:Button ID="btn" runat="server" Height="44px" Text="Submit" ClientIDMode="Static" 
         Width="207px" OnClick="btn_Click" /> 
       </td> 
      </tr> 
     </table> 
    </ContentTemplate> 
</asp:UpdatePanel> 
<asp:TextBox ID="isPostback" ClientIDMode="Static" runat="server"></asp:TextBox> 
<h1 style="color: Green; font-size: large; font-weight: bold; display: none;" id="nima"> 
    Progress ... 
</h1> 

,這是代碼bihind:

protected void btn_Click(object sender, EventArgs e) 
{ 
    System.Threading.Thread.Sleep(4000); 
    TextBox1.Text = "nima"; 
} 
protected void BindAgain_Click(object sender, EventArgs e) 
{ 
    Drp_1.SelectedIndex = 1; 
    Rad_7.SelectedIndex = 3; 
    isPostback.Text = "1"; 
} 

當我想用回發後以檢查isPostback值jQuery的我得到""。這是我的javascript代碼:

function pageLoad() { 
     $('#nima').hide(); 
     $(document).ready(function() { 
      //alert("NIMA"); 
      $("#Drp_1").on("change", function() { 
       if ($(this).val() == 2) { 
        if ($('#Rad_7 input:checked').val() != null && $('#Rad_7 input:checked').val() > 1 && $('#Rad_7 input:checked').val() != 2) { 
         if ($('#isPostback').val() == "0") {//<<<<<<<< 
          alert('Wrong option'); 
         } 
        } 
       } 
       else { 
        $('#Rad_7 input').removeAttr("checked"); 
       } 
      }).change(); 


      $("#Rad_7 input").on("change", function() { 
       if ($(this).val() == 2) { 
        if ($('#Drp_1').val() != null && $('#Drp_1').val() > 1 && $('#Drp_1').val() != 2) { 
         if ($('#isPostback').val() == "0") {//<<<<<<<< 
          alert('Wrong option'); 
         } 
        } 
       } 

       if ($("#Drp_1").val() != null && $("#Drp_1").val() == 2) { 
        if ($('#Rad_7 input:checked').val() != null && $('#Rad_7 input:checked').val() != 'undefiend' && $('#Rad_7 input:checked').val() != 2) { 
         if ($('#isPostback').val() == "0") {//<<<<<<<< 
          alert('Wrong option'); 
         } 
        } 
       } 
      }).change(); 

     }); 
    } 

    var prm = Sys.WebForms.PageRequestManager.getInstance(); 
    prm.add_initializeRequest(InitializeRequest); 
    prm.add_endRequest(EndRequest); 

    function InitializeRequest(sender, args) { 
     $('#nima').css('display', 'block'); 
    } 
    function EndRequest(sender, args) { 
     $('#nima').css('display', 'none'); 
    } 

哪裏是我的錯誤?

謝謝

+0

我測試你的代碼......這很奇怪 – Arian 2012-03-17 05:30:35

回答

1

您的文本框不在UpdatePanel中。當從面板內觸發回發時,它未收到更新。

相關問題