I want to get the "href" attribute of some "link" tags:
var linkTags = doc.DocumentNode.SelectNodes("//link[#href]");
var sources = linkTags.Select(t => t.GetAttributeValue("href", "")));
But the HTML file is actually a webforms ASPX page (a template). And the "href" attribute value is web forms variable tag:
<link href="<%= ResolveStaticUrl("~/print.css") %>" rel="stylesheet" type="text/css" />
As a result the value that I got became <%= ResolveStaticUrl(, the string between the double quotes.
Is it possible to tell HtmlAgilityPack to get the whole thing? In this case I want to get <%= ResolveStaticUrl("~/print.css") %>.
Related
I have been using grails for several weeks now, and have run into this problem when using the g:formRemote tag.
org.grails.taglib.GrailsTagException: [views/inventoryDetails/details.gsp:21] [views/inventoryDetails/details.gsp:21] Tag [formRemote] does not exist. No tag library found for namespace: g
for reference here is the .gsp page
<html>
<head>
<meta name="layout" content="bccmain" />
<title>Details - BCC Virtual Map and Inventory Tracker</title>
<g:javascript library="jquery" />
<link rel="stylesheet" href="${resource(dir: 'css', file: 'details.css')}" type="text/css">
<script>
$(document).ready(function () {
$("#database").addClass("active");
});
</script>
</head>
<body>
<div id ="content">
<g:formRemote name = "detailsUpdateForm" url = "[controller: 'InventoryDetails',action: 'ajaxUpdate']" update="updateBox">
<g:each in ="${details}" var = "d" status = "i">
<g:textField name="details" value = "${d.details}" class = "detailsblock"/>
<g:hiddenField name ="id" value = "${d.id}" />
<g:submitButton name = "submit" value = "Save" />
</g:each>
</g:formRemote>
<div id = "updateBox"></div>
</div>
</body>
</html>
I can't for the life of me figure out why the g:formRemote tag causes a problem, but other tags (run on different pages -- this one won't render) such as g:each will run without a problem. Thanks.
Most likely you are working on a Grails version that does not support "g:formRemote" any more. The formRemote tag and other Ajax related tags have been deprecated. You might want to think about a different approach.
I am trying to add a full html page into ckeditor for some editing via js.
Specifically, I execute the command
oEditor.insertHtml("<html><head><title>Hello</title></head><body><div>hello</div></body></html>");
But the result I get is the following:
<p>
<html>
<head>
<title></title>
</head>
<body>
</body>
</html>
</p>
<p>
<title></title>
</p>
<div>
hello</div>
The mode I use is:
config.fullPage = true
I tried also with fullPage = false, but not success.
Is there any way to insert to ckeditor a full html page?
Thanks a lot in advance!!
The insert* methods append the data to the editor contents, but if you want to replace the whole content then you must use setData.
I am working on MVC3, I am using Razor engine i have a layout.cshtml page which contains meta tag like
<meta property="og:url" content="http://www.mywebsite.com/" />
I have some content pages like abc.cshtml which has Layout.cshtml page as there's layout,so they are getting meta tags from layout.cshtml,i want that abc.cshtml should have its own meta tag like
<meta property="og:url" content="http://www.mywebsite.com/controller/abc" />
How can i do this? OR can i change meta tag dynamically??????
Yes you can pass that value from each or view action in ViewBag like below...
ViewBag.OgURL = "http://www.mywebsite.com/controller/abc";
then in you layout.cshtml
#ViewBag.OgURL
or set above head tag in you layout.cshtml..
#RenderSection("head", false)
and add in your view...
#section head {
<meta property="og:url" content="http://www.mywebsite.com/controller/abc" />
}
I'm new on Grails and I have some troubles with Ajax (so I could have missed something). On my main gsp I want a select box, that, when I click on its options, makes appear another field on the same page to select other things. As the content in the second part is dynamic, I need somme Ajax. Anyway I haven't succeed yet. Here is my code :
main.gsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="layout" content="main" />
<title>Sample title</title>
<g:javascript library="jquery"/>
</head>
<body>
<h1>Selection de l'email</h1>
<div class="dialog">
<g:select name="selectTemplate"
from="${templateCategories}"
value="category"
noSelection="['':'--- choisissez un modèle ---']"
onchange="${remoteFunction(
controller:"email"
action:"printTestTemplate"
update:"listTemplates"
params:'\'category=\'+this.value'
)}"
/>
<div id="listTemplates">RRR</div>
</div>
</body>
</html>
EmailController
def printTestTemplate = {
println params.category //doesn't print anything
println "YEAAAAAAAAAH" //the same
render(view:"formSelectTemplate", model:[templates:EmailTemplate.findByCategory(params.templateCategory)])
}
formSelectTemplate.gsp
<h1>YOUHOUUU !</h1>
I've both tried to call a view or template (by renaming the gsp of course), but nothing worked. Nevertheless I don't understand, I followed the official doc. Notice that the HTML result creates no event on the select box, and that Firebug tells me there is no 404. So I must have missed something in the creation of the box.
select result in HTML :
<select id="selectTemplate" name="selectTemplate">
<option value="Refus">Refus</option>
<option value="Informations complémentaires">Informations complémentaires</option>
</select>
Did you forget comas between the arguments of your remoteFunction call ? like this:
onchange="${remoteFunction(controller:"email",
action:"printTestTemplate",
update:"listTemplates",
params:'\'category=\'+this.value' )}"
I'm trying to load a view specific stylesheet in an asp.net mvc3 application (just learning this stuff!), so in my _Layout.cshtml I have:
<head>
<!--- All the common css & JS declarations here -->
#ViewBag.PageIncludes
</head>
<body>
Then in my controller I have:
public ActionResult Index()
{
ViewBag.PageIncludes = "<link rel='stylesheet' type='text/css' href='../Content/viewspecificstylesheet.css')' />";
return View();
}
However, when I view the page, even though the declaration is in the head, the text is rendered in the body, and thus rendered as text.
A couple of questions as a result:
Why, even though I declare in the head is this rendered in the body?
What is the best practice for loading a specific stylesheet for a given view/controller?
Thanks
You could use sections:
<head>
<!--- All the common css & JS declarations here -->
#RenderSection("Styles", false)
</head>
<body>
...
</body>
and then in the Index.cshtml view:
#section Styles {
<link rel="stylesheet" type="text/css" href="#Url.Content("~/Content/viewspecificstylesheet.css")" />
}
<div>This is the index view</div>
and your controller no longer needs to worry about styles which is purely view specific responsibility:
public ActionResult Index()
{
return View();
}