jquery 对话框在创建时会在 dom 中移动。创建对话框后,尝试将其移回表单标签:
$("#test").parent().appendTo($("form:first"));
编辑 - 这是更完整的代码:
<script type="text/javascript">
$(function() {
$("#view_test").click(function() {
$("#test").dialog({ show: 'slide', width: 600, title: 'View Check' });
$("#test").parent().appendTo($("form:first"));
});
});
</script>
<body>
<form id="form1" runat="server">
<div>
<div id="test">
<input type="checkbox" id="ch1" name="ch1" runat="server" />test
<input type="button" id="view_test" value="click" />
</div>
<asp:Button ID="btnSubmit" runat="server" Text="submit"
onclick="btnSubmit_Click" />
</div>
</form>
</body>
后面的代码:
public partial class Tests_Test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
Response.Write(ch1.Checked.ToString());
}
}