如何包括母版头的jquery不带路径的问题? [英] How to include jquery in masterpage header without path problems?

查看:88
本文介绍了如何包括母版头的jquery不带路径的问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经试过这种

<head id="Head1" runat="server">
<title>Back Office</title>
<link href="~/Styles/MasterPage.css" rel="stylesheet" type="text/css" />
<link href="Styles/custom-theme/jquery-ui-1.8.12.custom.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%= Page.ResolveClientUrl("~/scripts/jquery-1.5.1.min.js") %>"></script>
<asp:ContentPlaceHolder ID="HeadContent" runat="server">
</asp:ContentPlaceHolder>
</head>

该错误消息

我想太多,它只是发现使用此
    
遗憾

I think too much, it is just find using this sorry

推荐答案

看来,你试图控制动态添加到页面。在这种情况下,你可以使用下面的code

It seems that, you are trying to add controls to page dynamically. In this case, you can use the below code

var control = new HtmlGenericControl("script") ;
control.Attributes.Add("type", "text/javascript");
control.Attributes.Add("src", Page.ResolveClientUrl("~/scripts/jquery-1.5.1.min.js"));
//CDN will be best while hosting the application
//control.Attributes.Add("src", "http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js");
this.Page.Header.Controls.Add(control);

这篇关于如何包括母版头的jquery不带路径的问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆