asp.net文本框值为空当后博克与jQuery对话发生 [英] asp.net Textbox value is null when post bock with Jquery Dialog occured

查看:103
本文介绍了asp.net文本框值为空当后博克与jQuery对话发生的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有上述&lt Asp.net文本框; DIV>标签,它点击btnReply,℃之后, DIV>的jQuery对话框showes,让用户写主意文本框,然后点击发送按钮(jQuery的对话框按钮)和后背部happend。

,但在服务器端asp.net文本框值为空。为什么呢?
我的code是在这里:

 < D​​IV ID =ReplyDiv的风格=显示:无;>
             < ASP:文本框ID =txtReply=服务器文本模式=多行/>
     < / DIV>     <输入类型=按钮ID =btnReply的onclick =JavaScript的:retuen ShowReplyDialog();/>      < ASP:按钮的ID =AspBtnReply=服务器的OnClick =AspBtnReply_Click级=隐藏/>     / * ----- jQuery脚本---- * /
    <脚本类型=文/ JavaScript的>
      功能ShowReplyDialog()
       {
         $(#ReplyDiv)。对话框({
            宽度:580,
            纽扣: {
               关闭:函数(){$(本).dialog(亲密);},
               发送:功能(){
                   // ----调用Asp.net服务器方法在这里
                   $(#<%= AspBtnReply.ClientID%GT;)。点击();
               }
            }
         })父()。appendTo($(形式:一是));
      }
    < / SCRIPT>


解决方案

很多搜索我明白有一些原因后:


  1. 我可以解决它*的 jQuery UI的对话需要的z-index样式* 的。我的意思是:

     <风格>
     的.ui小部件的覆盖
     {
         Z-指数:0;
     }
    < /风格>

    和需要jQuery的:

      $(#..)对话框(.....)父()父()appendTo($(形式:一是));


  2. 它已经,因为我用的UpdatePanel一段时间,但我相信,在局部回传他们只发送更新的值,在他们里面的控件。因此,移动文本框的UpdatePanel内,或者使用JavaScript来填充UpdatePanel内隐藏的控制与文本框的背景下,只要是updated.item


  3. 要获得的输入值在后面的code,并通过服务器控制机制(textBox.Text),它们的状态(presence)访问它们需要在ViewState中坚持。既然你是用JavaScript构建他们,他们的状态不会持续存在,则可以使用Request.Form集合得到他们的价值的唯一方式。


  4. 这问题说最好的提示:<一href=\"http://stackoverflow.com/questions/5662263/jquery-dialog-postback-but-updatepanel-doesnt-get-updated\">jQuery对话框的回发的UpdatePanel,但没有更新 **


  5. 有关禁用控制最好的问题:
    检索ASP的值:文本框


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>

解决方案

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

这篇关于asp.net文本框值为空当后博克与jQuery对话发生的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆