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

时间:2014-07-29 09:02:52

标签: c# jquery asp.net

我想通过Jquery弹出窗口中的按钮来调用此代码。但用户名和密码最终为NULL

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

这是我弹出的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>

这是我调用弹出窗口的脚本:

<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>

1 个答案:

答案 0 :(得分:2)

这样可以解决..

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