Server Removes Spacing Between Head Tags

Jun 11, 2010

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.......................

View 5 Replies


Similar Messages:

HTML - Runat=server Removes Carriage Returns From Head Tag?

Jul 2, 2010

I'm new to .net, and I've noticed that when viewing my HTML source code generated by a .net application the carriage returns are removed from the head tag when it has runat="server" attribute on it.

I remove the runat="server" and the returns... return.

This really looks nasty when you have a few javascript and css files in your header because it ends up making the entire contents of the head tag 1 big line.

Just wondering if there's a way to control this or tell .net through configuration not to mangle the output?

View 4 Replies

Why Does URLs Get Encoded In <link> Tags Within <head Runat="server"> And How To Avoid It

Jan 4, 2011

(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?

View 2 Replies

Regular Expression That Removes Attributes From Tags?

Jun 22, 2010

What I'm interested in is a regular expression that will accept HTML input and remove all attributes inside the tag while leaving the tag intact. For example I want this...

<p class="test" id="TestParagraph">This is some test text right here.</p>

To become this...

<p>This is some test text right here.</p>

View 3 Replies

How To Set Head Tags In A Function In App_code

Mar 11, 2010

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

View 2 Replies

Using Code Blocks In Head Content And Link Tags?

Feb 1, 2010

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:

<link rel="shortcut icon" href="/App_Themes/<%=Page.Theme %>/images/bookmark.ico" type="image/x-icon" runat="server"/>

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:

<% Response.Write("<link rel="shortcut icon" href="/App_Themes/" + Page.Theme + "/images/bookmark.ico" type="image/x-icon"/>"); %>

I also tried it just with a string literal, and got the same error:

<%= "<link rel="shortcut icon" href="/App_Themes/" + Page.StyleSheetTheme + "/images/bookmark.ico" type="image/x-icon"/>" %>

Is there any way to reference something from the themes directory inside the link tag?

I'm trying to do this in both an ASP.NET 2 and an ASP.NET 2 MVC app.

View 3 Replies

Custom Control Render JavaScript Code In Head Tags?

Feb 3, 2011

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?

View 2 Replies

Visual Studio :: Remove The <head></head> Tag From And All Information Contained In The Tag

Mar 11, 2010

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.

View 5 Replies

Custom Server Controls :: Add Script Tag Within Head Tag In ServerControl?

Nov 7, 2010

I'm gonna use JQuery files in my custom ServerControl , So I inserted jquery-1.4.3.min.js file into the Solution in JavaScriptFiles Folder. Now, I have to add below line within Head tag whenever a user use this ServerControl.

<script type="text/javascript" src="JavaScriptFiles/jquery-1.4.3.min.js"></script>

How can I do it in ServerControl with C#

View 4 Replies

Master Page Has Runat=server On The Head Tag Element - It Is Injecting A Stylesheet Using Themes

Jul 15, 2010

master page has runat=server on the head tag element, it is injecting a stylesheet on the page for some reason and I am not doing it explicitly.

Is it a themes setting that is adding the stylesheet? How can I disable it for this master page?

View 1 Replies

Web Forms :: Inline Expression Or Binding Expression In The Server Head Section?

Aug 25, 2010

I write inline expression and binding expression in the server head section:

[Code]....

[Code]....

But both kinds of expression aren't parsed or executed except the ResovleUrl menthod. The html renders like this:

<head><link rel="stylesheet" type="text/css" href="<%= Request.ApplicationPath %>themes/style1.css" /><link rel="stylesheet" type="text/css" href="<%# Request.ApplicationPath %>themes/style2.css" />
<link rel="stylesheet" type="text/css" href="/themes/style3.css" />
<script type="text/javascript" src="/js/jwork.js"></script>
</head>

As I know, the inline expression in the attributes of server control can't be parsed but the binding expression should if we invoke the DataBind method. But the above case breaks the rule.

View 5 Replies

Render - Server Control Emitting Server Side Tags?

Feb 19, 2010

I'm new to writing custom ASP.NET server controls, and I'm encountering the following issue:

I have a control that inherits from System.Web.UI.HtmlControls.HtmlGenericControl. I override the control's Render method, use the HtmlTextWriter to emit some custom HTML (basically a TD tag with some custom attributes), and then call the case class' Render method.

Using the control:

<dc:Header id="header1" runat="Server" DataColumn="MemberNumber" Width="30%">Member Number</dc:Header >

The problem is that when I view my rendered HTML, the server tag is emitted to the client as well (right after the TD tag):

<dc:Header id="ctl00_ContentPlaceHolder_testData1_testData1_header1">Member Number</dc:Header>

How do I prevent this from happening?

View 1 Replies

AJAX :: Script Tags Rendered Inside The Body Tags?

Jun 26, 2010

i have created a aspx page with the script manager, update panels and so on. Now, when i use some jquery functions which are included inside the head tags, when the page is run, i find the script tags generated inside the body instead of the head tag. i'm using visual studio 2005 only.

View 2 Replies

C# - Forum Tags: Can Regex Be Modified To Grab Nested Tags?

Feb 24, 2011

I am building a forum and I want to use forum-style tags to let the users format their posts in a limited fashion.Currently I am using Regex to do this.As per this question:How to use C# regular expressions to emulate forum tags. The problem with this,is that the regex does not distinguish between nested tags.Here is a sample of how I implemented this method:

public static string MyExtensionMethod(this string text){return TransformTags(text);}
private static string TransformTags(string input)
{string regex = @"[([^=]+)[=x22']*(S*?)['x22]*](.+?)[/(1)]";
MatchCollection matches = new Regex(regex).Matches(input);
for (int i = 0; i < matches.Count; i++)
var tag = matches[i].Groups[1].Value;
var optionalValue = matches[i].Groups[2].Value;
var content = matches[i].Groups[3].Value;
Now,if I submit something like [quote] This user posted [quote] blah [/quote] [/quote] it does not properly detect the nested quote.Instead it takes the first opening quote tag and puts it with the first closing quote tag.Do you guys recommend any solutions?Can the regex be modified to grab nested tags?Maybe I shouldn't use regex for this?

View 3 Replies

SQL Server :: Get The Last 3 Tags That Added To The Db

Oct 11, 2010

I want get the last 3 tags that added to the db. My Tag table schema is:

TBL TAG:
CREATE TABLE [dbo].[tblTag](
[TagId] [int] IDENTITY(1,1) NOT NULL,
[Header] [nvarchar](200) NULL,
[IsActive] [tinyint] NULL DEFAULT ((0)),
[Ordered] [int] NOT NULL DEFAULT ((1)),
[Language] [nvarchar](5) NULL,
[DateTime] [smalldatetime] NULL,
[Official] [nvarchar](max) NULL,
[LastUpdate] [datetime] NULL,
[Locked] [tinyint] NULL,
[LastUpdateUser] [nvarchar](256) NULL,
[NumViews] [bigint] NULL,
[AllUserModified] [nvarchar](max) NULL,
CONSTRAINT [PK_tblTag] PRIMARY KEY CLUSTERED
(
[TagId] ASC
)

My TagtoMoudule table:

CREATE TABLE [dbo].[tbl_Module_Tag](
[AutoId] [int] IDENTITY(1,1) NOT NULL,
[ModuleId] [int] NOT NULL,
[ItemId] [int] NOT NULL,
[TagId] [int] NOT NULL
) ON [PRIMARY]

I want get the last 3 items in the tbl_Module_Tag but with no duplicate value, get uniq tags For exemple If the data the query "select tagid from tbl_Module_Tag order by autoid desc" return this values..........

View 5 Replies

How To Use ID Tags On Server Controls

Apr 28, 2010

Some of my servercontrols dont need ID's (i never need to access them from codebehind), removing them is rendering fine without comlaints. Is this ok?

why im dont want IDs? im using a .resx for different languages and from what I understand these must tied to a server control. And im tired of comming up with new pointless unique names. Also the these ID's gets insanly long as clientID.

View 1 Replies

Server Tags Cannot Contain Constructs?

Feb 24, 2011

I have a (image button)

<asp:ImageButton
ID="ImageButton1"
runat="server"
ImageUrl="../Images/checkout/Proceed_To_Checkout_Button.png"
onclick="top.location='<%=string.Format("MyAccount.aspx?action=new&returnUrl={0}",
Web.ProcessFlow.Common.QueryString(Request.QueryString["returnUrl"]))%>'"
/>

I get this error when I push the button:

Server tags cannot contain <% ... %> constructs.

I have tried <# too
it didn't help.

View 1 Replies

C# - Server Tags In Markup?

Feb 4, 2011

Morning all I have frequently used the old

<asp:Label ID="lblWas" runat="server" Text='<%# XPath("FACEVALUE") %>'></asp:Label>

This type of thing. when I first came across it I loved it, i'm using it again today but not quite so simply. I have a number of extra things I would like to achieve.

Apply formatting to the value. Like Text='<%# string.Format(XPath("FACEVALUE"), "{0:c}") %>'>
<asp:LinkButton ID="lnkBook" runat="server" PostBackUrl='/THEATRE/' + XPath("FACEVALUE")>Book</asp:LinkButton>

For option number 2 the URL is not as I would expect, and for number 1 I cannot get the syntax correct if it's even possible.

I have not been able to find something suitable in google. Hopefully what I am trying to achieve is obvious from the example :)

View 3 Replies

C# - .NET Server Tags Are Not Well Formed?

Aug 18, 2010

I want to use some server tags in OnClientClick of LinkButton

<asp:LinkButton ID="lnkbtnID" OnClientClick='<%# "window.open('SomePage.aspx?Id=" + Eval("reqID") + "');" %>' runat="server" Text='<%# Eval("reqID")%>'>
</asp:LinkButton>

how to write this, it is giving the error that Server tags are not well formed.So how to write this correctly?

View 2 Replies

How To Apply CSS Tags To <li> Tags When Using 4.0 Menu Control

Feb 1, 2011

Is there a way to apply your own CSS tags to <li> tags when using ASP .NET 4.0 menu control? For example, say I have an external style sheet that has tags "class1", "class2", "class3", and etc. I want to apply "class1" to the first menu item. Then if menu item is selected, I want to apply "class2" and if it's not selected, "class3". I played with various 'Static' styles, but just can't get it work. I finally gave up and created my own menu control that extends ASP .NET menu control and provides my own custom rendering. This works, but I'm wondering if there is a way to get it work with built-in menu control.

View 1 Replies

Rendering Server Tags At Runtime?

Feb 28, 2010

Is it possible that I reserve a asp.net code in db and load it at runtime. the asp.net code contains server side tags like Text='<%# Eval("Description") %>'

View 1 Replies

NumericUpDown Removes Zero For Decimals?

Aug 24, 2010

I have an AJAX NumericUpDown Control that takes a decimal. If I put in 1.30, it removes the zero. I do not want to remove the zero, it must remain at 1.30.

A demo of this can be found here: [URL]

For example, enter 1.30 in the text box then tab out or click somewhere else. The zero is removed.

View 2 Replies

MVC :: Whitespace Stripped Between Server Tags In View?

Jun 28, 2010

I'm rendering a view for the text/plain part of an e-mail. But in some cases, the whitespace is removed between non-output server tags, and I can't figure out why. Can someone explain why the following is missing the line breaks before the final line of output?

[Code]....

But this works - whitespace is preserved between output tags:

[Code]....

This is on MVC 2. It may have been on MVC 1 (or even in Web Forms), but I didn't notice it until today when I went to add a new line to the e-mail, so not sure of the source. Does ASP.NET or MVC have some optimization to try not to output whitespace between server tags?

View 10 Replies

C# - How To Generate Server - Side Tags Dynamiclly

Apr 19, 2010

I have an ASP.net page which contains some controls.

I generate this controls by code, [Actually I have a method which uses a stringBuilder and add Serverside tag as flat string on it]

My page shows the content correctly but unfortunately my controls became like a Client-side control

For example I had a LoginView on my generated code which dosen't work, and also I had read some string from LocalResources which dosen't appear on the page What Should I do to make my generating method correct

here is the code

protected string CreateSubSystem(string id, string roles, string AnonymousTemplateClass, string href, string rolesContentTemplateClass, string LoggedInTemplateClass)
{
StringBuilder sb = new StringBuilder();
sb.Append("<div class="SubSystemIconPlacement" id="");
sb.Append(id);
sb.Append(""><asp:LoginView runat="server" ID="");
sb.Append(id);
sb.Append(""><AnonymousTemplate><div class="");
sb.Append(AnonymousTemplateClass);
sb.Append(""></div><asp:Label ID="lblDisabled");
sb.Append(id);
sb.Append("" runat="server" SkinID="OneColLabel" meta:resourcekey="lbl");
sb.Append(id);
sb.Append("" /></AnonymousTemplate><RoleGroups><asp:RoleGroup Roles="");
sb.Append(roles);
sb.Append(""><ContentTemplate><a class="ImageLink" href="");
sb.Append(href);
sb.Append(""><div class="");
sb.Append(rolesContentTemplateClass);
sb.Append(""></div></a><asp:HyperLink runat="server" CssClass="SubSystemText" ID="lnk");
sb.Append(id);
sb.Append(" NavigateUrl="~/");
sb.Append(href);
sb.Append(" " meta:resourcekey="lbl");
sb.Append(id);
sb.Append("" /></ContentTemplate></asp:RoleGroup></RoleGroups><LoggedInTemplate><div class="");
sb.Append(LoggedInTemplateClass);
sb.Append(""></div><asp:Label runat="server" SkinID="OneColLabel" ID="lblDisabledLoggedIn");
sb.Append(id);
sb.Append("" meta:resourcekey="lbl");
sb.Append(id);
sb.Append("" /></LoggedInTemplate></asp:LoginView>");
sb.Append("</div>");
return sb.ToString();
}

I also use this method on page_PreRender event

View 1 Replies

C# - How To Pass Server Side Tags With JS Parameters

Dec 12, 2010

I have a loop in JS, and I want to pass each parameter in that loop to a function in ASP.NET in the codebehind.

something like that:

for (var i = 0; i < elements.length; i++)
{
}

And I want to pass a function in <%%> the elements[i].

How can I do that?

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved