日期:2014-05-17  浏览次数:20409 次

C#后台引用js文件?
我是这样写的,报$未定义,所以想应该是没有引用成功,请问该怎么修改啊?           
 if (string.IsNullOrEmpty(Session["UserId"] as string))
            {
                Response.Write("<script src='~/Scripts/jquery-1.10.0.js'></script>");
                Response.Write("<script src='~/Scripts/jquery-easyui/jquery.easyui.min.js'></script>");
                Response.Write("<script src='~/Scripts/jquery-easyui/locale/easyui-lang-zh_CN.js'></script>");
                Response.Write("<link href='~/Scripts/jquery-easyui/themes/default/easyui.css' rel='stylesheet' />");
                ClientScript.RegisterStartupScript(this.Page.GetType(), "", "<script language='javascript' >$.message.alert('您的下载方式错误,请登陆后下载');</script>");
            }
C# JavaScript

------解决方案--------------------
Response.Write("<script src='~/Scripts/jquery-1.10.0.js'></script>");
                Response.Write("<script src='~/Scripts/jquery-easyui/jquery.easyui.min.js'></script>");
                Response.Write("<script src='~/Scripts/jquery-easyui/locale/easyui-lang-zh_CN.js'></script>");
                Response.Write("<link href='~/Scripts/jquery-easyui/themes/default/easyui.css' rel='stylesheet' />");

把里面引用的script放到head当中,Response.Write直接刷到页面最顶层。
------解决方案--------------------
            LiteralControl control = new LiteralControl();