我想在 C# 代码隐藏中使用 Response.Write
调用 jQuery 对话框方法。我尝试使用 RegisterScriptBlock
Response.Write("<script> $(document).ready(function () {$('#divOutputWindow').html('You are not authorised to view this Page..!!').dialog({title: 'Notice...',show: 'slide',hide: 'blind',modal: true,buttons: {'Ok':function(){window.location = 'Default.aspx';}}});});</script>");
我的所有 jQuery 都已正确包含,因为我能够从我的 JS 文件调用对话框。编号:divOutputWindow
出现在 .aspx 页面上
仍然看不到 jQuery 对话框。
附言: 我的 .aspx 页面不包含 <form>
标记 因此 RegisterScriptBlock
不会工作
最佳答案
它没有起作用,因为 Response.Write 在页面顶部添加了代码块。通过这种方式,脚本在加载 jq 库之前执行。 您需要使用 ScriptManager 和 RegisterClientScriptBlock。
关于c# - Response.Write C# 代码隐藏中的调用 jQuery 对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16653138/