I'm building an asp.net app using themes, and I've assigned a theme to the app using the web config.
I have a bookmark icon that I want to use for my page and it is located in the themes directory, but I am having trouble referencing the themes location from a link tag in my header.
First I tried putting a code block inside the link tags href element, which did not work. Instead all it did was html encode the <% characters and output it directly to the browser:
I am able to put a code block inside an element in an hr tag though, so I don't know why it won't work in a link tag:
<hr test="<%=Page.Theme %>"/>
Then I tried doing a Response.Write inside the head tag, but I got an error saying the Controls collection cannot be modified because the control contains code blocks:
I am creating a custom control and was wondering if it is possible to render any JavaScript in the head tags of the page it is placed on? I am thinking I would need to use the FindControl method, but am not sure what I need to bind to. I am thinking the page object? Let me know if I am thinking in the right direction or if there is another option.
My only concern with the above mentioned idea is that how do I render all my content while placing some code in the head tags?
(I have tested this with a vanilla asp.net site running from the webdev server and it is a problem here also):
I have the following markup in my .master file
[code]....
Clearly Asp.Net does something to encode the url. As it happens, I really need the head tag to be runat="server" and I would also like to be able to have "&" in link-urls within it is there some trick I can use to have my cake and eat it too?
The below function has to be put within my common functions file in app_code folder. how do I do it?
It gives error like this:
Reference to a non-shared member requires an object reference
Public Sub setHeadTags(ByVal title As String, ByVal description As String, ByVal keywords As String) Dim metaDescription As HtmlMeta = DirectCast(Page.Master.FindControl("metaDescription"), HtmlMeta) Dim metaKeywords As HtmlMeta = DirectCast(Page.Master.FindControl("metaKeywords"), HtmlMeta) metaDescription.Attributes.Add("content", "My big content description") metaKeywords.Attributes.Add("content", "all, are, my, keywords") Dim pageTitle As HtmlTitle = DirectCast(Page.Master.FindControl("pageTitle"), HtmlTitle) pageTitle.Text = "Hey hey heY" End Sub
I haven't been able to find relevant information through searches. I'm very green when it comes to sever side scripting. I have an ASPX page with a standard form. In the head I have meta tags, the title tag, and a link tag neatly ordered on their own lines. However, when viewing the source code after publishing to the server, the spacing between the tags is removed and it looks quite messy. (There are also <style> and <script> tags that follow, but they remain unaffected.)
I realize this has no practical effect on the site itself (in an SEO sense or otherwise). My project manager shows the source code to our clients to educate them on meta tags and page titles. It would help if it wouldn't become jumbled like this. I wonder if this is a common issue and if it's possible to prevent through better coding practices. HTML as authored, with tags separated on their own lines:
HTML Code:
<head runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="description" content="Welcome to Lawn Care Waukesha - Cut My Lawn. Cut My Lawn - Lawn Care Services has offered quality lawn cutting, fertilizing, aerating, and much more at affordable pricing since 2002! We currently offer lawn care service to Waukesha, Brookfield, Pewaukee, Menomonee Falls, and surrounding communities." /> <meta name="keywords" content="lawn cutting, lawn mowing, lawn care, fertilizing, aeration, mulching, shrub trimming, lawn mowing, edging, pruning, mulching, weed control, waukesha, Brookfield, Pewaukee, menomonee falls" /> <title>Lawn Care Waukesha — Cut My Lawn, Lawn Care Service</title> <link rel="shortcut icon" type="image/x-icon" href="favicon.ico" /> HTML after being processed by the sever, with all the tags running together:
HTML Code: <head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta name="description" content="Welcome to Lawn Care Waukesha - Cut My Lawn. Cut My Lawn - Lawn Care Services has offered quality lawn cutting, fertilizing, aerating, and much more at affordable pricing since 2002! We currently offer lawn care service to Waukesha, Brookfield, Pewaukee, Menomonee Falls, and surrounding communities." /><meta name="keywords" content="lawn cutting, lawn mowing, lawn care, fertilizing, aeration, mulching, shrub trimming, lawn mowing, edging, pruning, mulching, weed control, waukesha, Brookfield, Pewaukee, menomonee falls" /><title> Lawn Care Waukesha — Cut My Lawn, Lawn Care Service </title><link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
I'm not sure it's relevant, but here's the script used to send the form (which I didn't write, by the way). It's the final tag inside the page head:
HTML Code: <script type="" runat="server"> Protected Sub SubmitForm_Click(ByVal sender As Object, ByVal e As System.EventArgs) If Not Page.IsValid Then Exit Sub Dim SendResultsTo As String = "email" Dim smtpMailServer As String = "smtp" Dim smtpUsername As String = "email" Dim MailSubject As String = "subject" Try Dim txtQ As TextBox = Me.FormContent.FindControl("TextBoxQ") If txtQ IsNot Nothing Then Dim ans As String = ViewState("hf1") If ans.ToLower <> txtQ.Text.ToLower Or ans.ToUpper <> txtQ.Text.ToUpper Then Me.CutMyLawnForm.ActiveViewIndex = 3.......................
how can i add title and meta tags for content pages in a project base on master and content page(dinamically) ?
i used the blow method for master page :
[code]....
and the error is :(in line *)
Error 17 'System.Web.UI.MasterPage' does not contain a definition for 'SetMetaTags' and no extension method 'SetMetaTags' accepting a first argument of type 'System.Web.UI.MasterPage' could be found (are you missing a using directive or an assembly reference?)
I have several hundred html files that I want to remove the <head></head> tag from and all information contained in the tag. I am fairly sure I can do this in Visual Studio using the Find and Replace In Files with REGEX.
I am writing a dynamic control that I want to pass in something along the lines of the following:
HyperLink myLink = new HyperLink(); myLink.NavigateUrl = "/Home.aspx?id=<%= DataBinder.Eval("PageId") %>"; myLink.Text = "The link"; myControl.Controls.Add(myLink);
I want to be able to resolve the myLink.NavigateUrl at run-time according to the context that myControl puts the control into in the end (this is not a WebControl and therefore adding to the collection of controls doesn't output to page).
vote-up@{puzzle.UserVote .... is not treating the @ symbol as a start of a code block @puzzle.UserVote == VoteType.Up looks at the first part @puzzle.UserVote as if it's supposed to render the value of the variable.
i saw few of solutions for this exception (like putting it in place holder, or replace the <% to <# ...etc) , but i don't get the idea about it, i mean what is the controls collection? and why it can't be modified if the added control contains code blocks?
I recently put some code <% %> code blocks in my Master Page. Note I've read of the "fix" for either moving things out of <head> or using <%# %> but neither of them work well for my application.
Now the weird thing is that I only get this error on one page of mine. All the other pages seem to work fine, so what actually causes this error? There is nothing I can think of that is unique about this page. It uses the script manager as does other working pages and there is just nothing extraordinary about this page. It does have quite a few custom controls on it, so hunting down what is different in this page is more difficult than usual.
So what actually causes the Controls collection cannot be modified because the control contains code blocks exception?
We are using Infragistics' WebDataGrid, but this question probably applies to all other grids. I am new to Infragistics (actually have worked with their controls years ago, but feeling new regardless!) and this application as well. So I'm looking to its existing code as a model.
I want to have a column called Tobacco with a Y or N value depending on if Smoker is true/false.
Ideally, the whole thing would be something like this:
I don't know if I need a Convert.ToBoolean in there somewhere but I tried and it didn't work and at this point I am just guessing which will take a long time for me to get it right.
I have been trying to create dynamic path for my css files to allow statrup application regardless of application path. I have srtange behavious with <%=
[Code]....
I believe above should generate app path, but it looks <%= is ignored and the code on my webside looks like this
[Code]....
When I move <%=Request.ApplicationPath%> outside href attribute or move whole link tag to body it works fine
I am getting http exception in of the method of class file (search.aspx.vb) like "The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)",
I have tried placing Java script function in the body of Master page from header, whereas I just removed the Java script tag and its contents in search.aspx (as of its not required now). Still getting exception.Â
I also know that if we have something like this <%= in Java script function we need to replace with <%#. But I don’t have this kind of code in any function.
I want use meta tag in my page that read keyword from database
I set this code in my product.aspx pageÂ
protected void Page_Load(object sender, EventArgs e) { SqlCommand _cmd = new SqlCommand("select Keyword1 + ',' + Keyword2 + ',' +Keyword3 from House_info where BehCode=1115", _cn); _cn.Open(); SqlDataReader _dr = _cmd.ExecuteReader(); while (_dr.Read())
[Code] ....
It worked correctly and show my keywords from database and show it in my product.aspx metatag
I have two other page
index.aspx  and store.aspx  in index.aspx i have 1button and 1 TextBox when user type their BEHCODE(columns name in users table) in TextBox it go to store.aspx page and show that users information on store.aspx
Now i want set meta tag in store.aspx page and i want  fill store.aspx  meta tag from my users table in data base
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
In this line
this.Page.Header.Controls.Add(htmlMeta); Â I use this code tooÂ
<script type="text/javascript"> Â Â Â Â $("input[id$=btnButton]").live("click", function () { Â Â Â Â Â Â return confirm("Do you want to submit?"); Â Â Â Â }); Â Â </script>
But it didn't worked this problem just happen here when i used  meta tag code in  other page it worked correctly . Why this happen?
I am struggling with something that I guess should be standard practice really. I have a number of user controls that use some JQuery plugins. I do not really want to link to the extra CSS and JS files from my main masterpage as this would cause extra load to the user the first time they hit the site, (admittedly it would only be the once), so I was just putting them links into the top of the user control. Then I looked at my source HTML, not nice! Even worse for controls that repeat multiple times on a page.
So I was thinking is there a way of injecting them into the Head of the page when they are needed from the User Control. For that matter is there a way of doing it to the footer for JS stuff?
The code on one of my aspx pages is giving me this error:
I'm getting this on the code behind for export to excel on one of my pages.
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).It is referring to this line Me.GridView1.Parent.Controls.Add(frm)
I have this code in the aspx page. I am using two gridviews. I need to have this on the page any way I can fix the code so I can use that export to excel you created?
 <% If(Session("PendingClaims"))%>then display gridview1<%Else%>
and it was working well even After I upgraded my wevbsite to .net version 4 but when I started a new website from scratch in vs2010 using .net4 when I use ajax toolkit in this new site it is registered as folowing
and when I run the page I get the error The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>) I don't Know what is the reason for this. I noticed another thing. in my old website I was using thckbox script by using the files common.js, jquery-1.3.2.js,jquery.thickbox.js and puting them in a Javascript folder ad then registering them in Script manager as following
this was working well also but in my new site the jquery file version was jquery-1.4.1.js but also I added the old version f the javascripts files in the built in Scripts folder that is created by default b the new site and followed the same way in registering them in the script managerchange the JavaScript folder to the built in folder Scripts
but this doesn't work also in the new site I think that there is something diffirent in the 2 case which leads to this change in performance I wish your support and advice about how to solve this matter
I'm using a jQuery modal form to gather some information about a user and then redirecting them to another view. However, my submit button will not fire because none of the content is rendering inside the form tags on the generated output.
I'm currently using ASP.NET MVC 2 and the spark view engine. The main master page (application.spark) contains all of the CSS link tags that need to be present for all pages (global stuff). However, I have some content pages that have page specific CSS tags and currently I'm just sticking the link tag in the body as something like:
My problem is that when the page renders, this tag ends up in the which is not where it needs to be. Is there a solution for this?
I had was to check the controller in the Application.spark page and write out which page specific css file is required for that particular controller, however, that solution doesn't seem to scale well and I would imagine there is some way of creating the link in the child page and having it render where it's supposed to by the browser.