我正在开发一个Web应用程序,其中多个对话框相互打开。如何在asp.net Web应用程序中附加和显示来自cs文件的对话框,以便代码变得更易于管理。
$("#dialog1").dialog({
autoOpen: false,
modal: true,
draggable: true,
height: 340,
width: 400,
position: "center",
resizable: false,
buttons: {
"Yes": function () { $("#dialog1").dialog("close") },
"No": function () { }
}
});
$("#btnDialog").click(function () { $("#dialog1").dialog("open"); });
答案 0 :(得分:0)
HTML
<form id="form1" runat="server">
<div id="dialog-modal" style="width: 200px; height: 200px; background-color: gray;display:none">
hi
</div>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
</form>
背后的代码 -
protected void Button1_Click(object sender, EventArgs e)
{
bool success = true;//set to true if save successful
if(success)
Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "testScript", " $(document).ready(function() { $('#dialog-modal').dialog();});", true);
}
}
答案 1 :(得分:0)
尝试在后面的代码中编写js变量并在页面中使用它
protected void Button1_Click(object sender, EventArgs e)
{ Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "ShowDialog",
" var showDialog="+boolShowDialog, true);
}
}
在页面
<script>
if(showDialog==true){
$(document).ready(function(){
$('#dialog-box').dialog("show");
});
}
</script>