日期:2014-05-17 浏览次数:20521 次
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="testJqFun.aspx.cs" Inherits="testJqFun" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" > function jqueryFun() { alert("我是被后台调用的"); alert("用jq获取div内容为:"+$("#d1").html()); } </script> </head> <body> <form id="form1" runat="server"> <div id="d1" style="display:none"> asdfasdf </div> </form> </body> </html>
------解决方案--------------------
<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { string op = Request.QueryString["op"]; switch (op) { case "1": Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script defer>" + myalert("1") + "</script>"); break; case "2": break; default: break; } } private string myalert(string msg) { return "Boxy.alert(\"" + msg + "\",'',{title:\"提示\",modal:true,closeable:true});"; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>无标题页</title> <script src="/js/jquery-1.3.2.min.js" type="text/javascript"></script> <script type='text/javascript' src='/js/jquery.boxy.js'></script> <link rel="stylesheet" href="/css/boxy.css" type="text/css" /> <link href="/images/skin.css" rel="stylesheet" type="text/css" /> </head> <body> <form id="form1" runat="server"> <div> </div> </form> </body>