2012-03-17 2 views
0

пожалуйста, рассмотрите этот код:TextBox не получает это значение из кода позади после постбэка

<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

ответ

1

Ваше текстовое поле находится за пределами UpdatePanel. Он не получает обновление, когда функция обратной передачи запускается из панели.

Смежные вопросы