代码背后的Jquery消息框 [英] Jquery Message Box from Code Behind
本文介绍了代码背后的Jquery消息框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hi EveryOne,
我想从后面的代码中显示一个Jquery消息框。我试过但它没有显示消息框。我已经检查了保持调试器,控制是在javascript方法中但没有显示消息框。
请查看代码一次:
Hi EveryOne,
I want to dispaly a Jquery message box from code behind. I have tried but it is not displaying a message box. I have checked with keeping a debugger, controlling is coming in the javascript method but not displaying the message box.
Please look into the code once:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ModalFromCodeBehind.aspx.cs" Inherits="JQUI_ModalFromCodeBehind" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="../Scripts/jquery-2.0.2.js"></script>
<script src="../Scripts/jquery-ui-1.10.3.min.js"></script>
<link href="../Content/themes/base/jquery-ui.css" rel="stylesheet" />
<script type="text/javascript">
function jqcall() {
debugger;
$('#d1').dialog();
console.log('dialog');
return false;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button Text="text" runat="server" id="btn" OnClick="btn_Click"/>
<div id="d1" style="display:none;" title="Web Synergies">
Hi, Wel Come to Hello World
</div>
</div>
</form>
</body>
</html>
调用Javascript函数的服务器端代码:
Server side code to call Javascript function :
protected void btn_Click(object sender, EventArgs e)
{
ScriptManager.RegisterClientScriptBlock(this, GetType(), "Sc", "jqcall();", true);
}
推荐答案
(' < span class =code-string>#d1')。dialog();
console .log(' dialog'< /跨度>);
return false ;
}
< / script >
< / head >
< 正文 >
< form id = form1 runat = 服务器 >
< div >
< asp:按钮 文字 = text runat = server id = btn OnClick = btn_Click / >
< div id = d1 style = display:none; title = 网络协同作用 >
Wel来到Hello World
< / div >
< / div >
< / form >
< / body >
< / html >
('#d1').dialog(); console.log('dialog'); return false; } </script> </head> <body> <form id="form1" runat="server"> <div> <asp:Button Text="text" runat="server" id="btn" OnClick="btn_Click"/> <div id="d1" style="display:none;" title="Web Synergies"> Hi, Wel Come to Hello World </div> </div> </form> </body> </html>
调用Javascript函数的服务器端代码:
Server side code to call Javascript function :
protected void btn_Click(object sender, EventArgs e)
{
ScriptManager.RegisterClientScriptBlock(this, GetType(), "Sc", "jqcall();", true);
}
测试以下代码:
test the following code :
protected void btn_Click(object sender, EventArgs e)
{
ScriptManager.RegisterClientScriptBlock(this, GetType(), "Sc", "alert('OK');", true);
}
另外,你应该使用jquery更标准。像这样:
Additional,you should use jquery more standard .like this :
( document )。ready(< span class =code-keyword> function (
这篇关于代码背后的Jquery消息框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文