I have following variable to be used as a public variable in the application. As you can see it has the main domain of the website as its value. The issue is, once the application is loaded it does not have any value, I need to refresh the page for it to have its correct value.
<c:set var="url" scope="application"
value="http://www.example.com" />
I am using Tiles3 and this line is in baseLayout.jsp file.
Code
<link rel="stylesheet"
href="${url}/resources/mystyle.css">
At first the addresses in the source of the page that are supposed to have the URL value are as following
<link rel="stylesheet"
href="/resources/mystyle.css">
After refreshing the page the address will become as following
<link rel="stylesheet"
href="http://www.example.com/resources/mystyle.css">
in your baseLayout.jsp, use
<link rel="stylesheet" href="resources/style.css" />
Dont write ${url}
Related
I ran into an issue with linking my css files in master page.
<SharePoint:CssRegistration ID="StyleSheet1" Name="~sitecollection/_catalogs/masterpage/Resources/css/quack_1200.css" After="corev15.css" runat="server" />
<SharePoint:CssRegistration ID="StyleSheet2" Name="~sitecollection/_catalogs/masterpage/Resources/css/main.css" After="corev15.css" runat="server" />
These files are not being loaded. When I access the console in browser it doesn't show any errors and when I investigate the HTML it does not show the CSS files.
However if I access the files on the URL they do exist.
This is the deployment XML definition.
<File Path="Resources\css\main.css" Url="masterpage/Resources/css/main.css" IgnoreIfAlreadyExists="TRUE" Type="GhostableInLibrary" />
<File Path="Resources\css\quack_1200.css" Url="masterpage/Resources/css/quack_1200.css" IgnoreIfAlreadyExists="TRUE" Type="GhostableInLibrary" />
If I type the whole URL I am able to access the files.
http://[computer
name]/sites/PCF/_catalogs/masterpage/Resources/css/quack_1200.css
http://[computer
name]/sites/PCF/_catalogs/masterpage/Resources/css/main.css
Could you please help me on resolving this issue.
Thank you
The problem is that CssRegistration doesnt handle the ~sitecollection token.
I havent tested this, but try to add:
<link rel="stylesheet" type="text/css" href="resources/css/main.css" />
If you cant figure out how to build up your url, you could always add the css files with javascript / jQuery.
var linkTag = '<link href="' + _spPageContextInfo.siteAbsoluteUrl + '/_catalogs/masterpage/Resources/css/quack_1200.css" rel="stylesheet" type="text/css"/>';
$(document).ready($('head').append(linkTag);
Where you are adding your css files in master page or in html page?In SP2013 you cannot do any modifications directly on master page. What ever you want to do, you should do in a html page only. In html page add your css file like below.
<link rel="stylesheet" type="text/css" href="../../../../images/MyFolder/css/styles.css" />
If you save this html page and see in the master page it will render like below
<SharePoint:CssRegistration name="<% $SPUrl:~sitecollection/images/MyFolder/css/styles.css %>" runat="server" after="SharepointCssFile"/>
Note : if your changes not applying in your master page try to convert the associated html file once again. Check this MSDN Link
Solved with:
<link rel="stylesheet" type="text/css" href="Resources/css/quack_1200.css" />
<link rel="stylesheet" type="text/css" href="Resources/css/main.css" />
</head>
In my Layout.cshtml file I have the following line:
<link rel="stylesheet" href="~/Content/bootstrap.css" />
My assumption was that since I did not include Url.Content() call, it would actually just render what I wrote but not expand the virtual URL automatically. This assumption is wrong - the generated HTML does include the correct path to the file, not the virtual path I entered.
If I wrap the <link> in <script>
<script type="text/html">
<link rel="stylesheet" href="~/Content/bootstrap.css" />
</script>
then the URL is not expanded.
Which part of ASP.NET MVC does this automatic parsing of HTML and is there a way to control it?
This was a new feature included in Razor2 and ASP.NET MVC 4 and was designed to make life easier by not having to use Url.Content everywhere.
http://www.davidhayden.me/blog/asp.net-mvc-4-the-new-tilde-slash-feature-in-razor-2
The feature only works inside standard HTML attributes and that's why you don't get it inside your <script> tag or anywhere else.
You could use a simple output write to work around this:
<link rel="stylesheet" href="#("~/Content/bootstrap.css")" />
Can anyone know how to pass the servlet context value in gsp page.
I need to pass the servlet context value customcss to the resource link.
If I print the ${application.customcss} in my gsp page I am getting the value as main.css.
But when i try to pass the same to file link then its not taking the ${application.customcss} value.
<link rel="stylesheet" href="${resource(dir: 'css', file:'${application.customcss}')}" type="text/css">
In my page the link is get not get created properly.Its directly taking the ${application.customcss} as a file.
<link rel="stylesheet" href="/SAM-1.0/css/${application.customcss}" type="text/css">
try:
<link rel="stylesheet" href="${resource(dir: 'css', file: application.customcss)}" type="text/css">
${resource(... is already Groovy code, you don't need to use another block of ${..} inside
I'm getting mad. Site.master page contains the following line within head tag. When the project starts I can see in firebug Net panel that this line is ignored. Even I don't get 404 not Found error;
<link href='<%=Page.ResolveUrl("~/NewStyles/ui-lightness/jquery-ui-1.8.20.custom.css")%>' type="text/css" />
What's wrong with it?
Try using a pound sign and call Page.Header.DataBind
<link href='<%# Page.ResolveUrl("~/NewStyles/ui-lightness/jquery-ui-1.8.20.custom.css")%>>' type="text/css" />
I am implementing a web application using ASP.NET MVC3. In the application I want to add the option of switching between CSS files (for themes) based on clicking some links. I did some research and I came up with the following:
To pass data to site.master, the good solution is to create an abstract controller and inherit that into the other controllers that have site.master as their template, according to this article: Passing Data to View Master Pages
I can pass a viewbag message to the link which controls the css file URL to set the current css file to use, based on the code that I am seeing being passed to scripts at the top of the site.master page:
script src="<%: Url.Content("~/Scripts/jquery-1.5.1.min.js") %>" type="text/javascript"
So I created an abstract controller, ApplicationController, with the following method:
public ApplicationController()
{ViewBag.NewMessage = "../../Content/Site2.css";}
And in the site.master, I included this link:
<link href="<%: (string) ViewBag.NewMessage %>" rel="stylesheet" type="text/css" />
However, that doesn't seem to be working, as it is being interpreted as:
<link href="<%: (string) ViewBag.NewMessage %>" rel="stylesheet" type="text/css" />
And only when I remove the quotation marks:
<link href=<%: (string) ViewBag.NewMessage %> rel="stylesheet" type="text/css" />
is it being interpreted correctly (and the webpage gets rendered with the correct css), except that it violates html standards:
<link href=../../Content/Site2.css rel="stylesheet" type="text/css" />
Any suggestion about how to go tackling this problem or is there a more elegant solution I'm missing? I was going to proceed and implement variables in the ApplicationController that get selected based on links the user clicks at the top of the page, to switch between css styles.
Thank you!
Check to make sure your <head> tag does not have runat="server".
After making this change, be sure to check your script and css tags. This change can break the paths if you use the ~/ to ref app root. To help with this, use the Url.Content(...) helper.