简体   繁体   English

无法从Jquery弹出窗口中的asp:textbox中获取数据,其背后的代码

[英]Unable to get the data from asp:textbox in Jquery popup in code behind

I want to call this Code behind method through a button which is in Jquery popup. 我想通过Jquery弹出窗口中的按钮在方法后面调用此Code。 But username and password are ended up being NULL 但是用户名和密码最终为NULL

protected void btnSave_Click(object sender, EventArgs e)
{
    string strUName= txtNewUname.Text;
    string strUpass = txtNewPassword.Text;
}

Here is my Html for the Popup 这是我的弹出式HTML

<body>
    <form runat="server">
        <input type="button" id="btnNew" text="NEW" value="ADD" onclick="ShowAddNewPopup()"/>
             <div id="alertPopup" title="Add New User" style="display :none" >
             <table>
                 <tr>
                     <td class="auto-style2">UserName
                     </td>
                     <td>
                         <asp:TextBox runat="server" ID="txtNewUname" ClientIDMode="Static"></asp:TextBox>
                     </td>
                 </tr>
                 <tr>
                     <td class="auto-style2">Password
                     </td>
                     <td>
                         <asp:TextBox runat="server" ID="txtNewPassword" ClientIDMode="Static"></asp:TextBox>
                     </td>
                 </tr>
                 <tr>
                    <td colspan="2">
                        <asp:Button runat="server"  ID="btnSave" OnClick="btnSave_Click" UseSubmitBehavior="false" Text ="save"/>
                    </td>
                </tr>
            </table>
        </div>
    </form>
</body>

Here is my Script to call the popup: 这是我的脚本来调用弹出窗口:

<head runat="server">
    <title></title>
    <link rel="stylesheet" href="//code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css">
    <script src="//code.jquery.com/jquery-1.10.2.js"></script>
    <script src="//code.jquery.com/ui/1.11.0/jquery-ui.js"></script>
    <script>
     function ShowAddNewPopup() {
         debugger;
         $("#alertPopup").dialog();
     }
    </script> 
</head>

this will work out.. 这会解决..

$("#alertPopup").dialog({
                appendTo: "form"
            });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM