3

I have Asp.net text box in < div> tag which after click on "btnReply",< div> showes by Jquery Dialog, so user write idea at text box and click "Send" button (jquery dialog button) and post back happend.

but the asp.net text box value at server side is null . Why ? my code is here :

     <div id="ReplyDiv"  style="display:none;">
             <asp:TextBox ID="txtReply" runat="server" Textmode="MultiLine"/>
     </div>

     <input type="button" id="btnReply" onclick="javascript:retuen ShowReplyDialog();"/>

      <asp:Button ID="AspBtnReply" runat="server" OnClick="AspBtnReply_Click" class="hidden"/>

     /*-----Jquery script----*/
    <script type="text/javascript">
      function ShowReplyDialog()
       {
         $("#ReplyDiv").dialog({
            width: 580,          
            buttons: {
               "Close": function () { $(this).dialog("close");} , 
               "Send" : function () {
                   //----Call Asp.net server method here
                   $("#<%=AspBtnReply.ClientID %>").click();
               }                    
            }
         }).parent().appendTo($("form:first"));
      }
    </script>
Harry Sarshogh
  • 2,137
  • 3
  • 25
  • 48

3 Answers3

5

After a lot of search i understand to have some reasons :

  1. I can solved it **Jquery UI Dialog need z-index style ** . i mean :

    <style>
     .ui-widget-overlay
     {
         z-index:0;
     }
    </style>
    

    And need jquery :

      $("#..").dialog(.....).parent().parent().appendTo($("form:first"));
    
  2. It's been a while since I used UpdatePanels, but I believe that on partial postback they only send updated values for controls inside them. So move the TextBox inside the UpdatePanel, or perhaps use Javascript to populate a hidden control inside the UpdatePanel with the contexts of the TextBox whenever it is updated.item

  3. To get the values of the inputs in the code behind and access them through the server controls mechanism (textBox.Text), their state (and presence) needs to be persisted in the ViewState. Since you are building them with javascript, their state is not persisted, the only way you can get their values is using the Request.Form collection.

  4. This issue said best tips : jQuery Dialog-Postback but UpdatePanel doesn't get updated**

  5. For disable controls is best issue : Retrieving the value of a asp:TextBox

Community
  • 1
  • 1
Harry Sarshogh
  • 2,137
  • 3
  • 25
  • 48
3

Use hidden field value to store the textbox value

var Des = $("#txtDesc").val();
$("#hid").val(Des);

hid is the id of hidden field.

Aarif Qureshi
  • 474
  • 1
  • 3
  • 13
  • Hi Aarif , i can solved it but i want to know Why the text box value don't sended to server.!!! i also up your solution but exactly not my answer you said. Thanks – Harry Sarshogh Aug 30 '13 at 15:22
  • 2
    Jquery UI on run time removes the all document objects and puts it out side the DOM at this time none of the objects will be accessible for you . Thats the default behavior of all Jquery UI plugins . So you have to bear that some how by changing the way you are using it . – Aarif Qureshi Sep 02 '13 at 05:20
0

I've just faced the same issue and after two hours effort i found the form tag in my bootstrap Modal. I've removed the form tag and value is receving in backend.

Moeed
  • 43
  • 4