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


Similar Messages:

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

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

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

Web Forms :: Carriage Returns In A TableCell?

Mar 23, 2010

I have a tablecell where I import the text from a SQL database and this all works well, except that the carriage returns are not being displayed in the text.

I have done some googling and although I do not get any error messages, the carriage returns are not appearing in my table cell.

Here is the code:

[Code]....

I have also tried Environment.NewLine, etc. but all to no avail.

View 2 Replies

C# - How To Retain Carriage Returns After Encrypting Data

Apr 9, 2010

I have this following setup, a textarea named with some data in it that may have carriage returns and another textarea that has style='display:none' in order to make it hidden as follows:

<textarea id="myTextarea" onBlur="encryptMyData()">

View 3 Replies

Web Forms :: Carriage Returns Not Getting Entered Into Database?

Jan 4, 2010

I've got a text box on my page called txtNotes - multiline textbox.

When I add the text into the sql server database, the line feeds are not getting entered.

I have a function that replaces the line feeds with "<br>" and it's still all in one line. Also I don't see the normal square type entity after each line in the database, that is normally there for a line feed.

However, when I copy from the database and paste it to Notepad, it is formatted correctly

[Code].....

View 10 Replies

VS 2005 - Multiline Textbox Not Recognizing Carriage Returns

Jan 7, 2014

I have an ASP.NET multiline textbox. I can hit return to create carriage returns on the screen but the text property of the textbox is ignoring the carriage returns and simply concatenating the lines without even a space in between. I am writing this text property to a database and I want to be able to retrieve the text exactly as it was typed with carriage returns included.

View 2 Replies

C# - Export To Excel Leaves [?] On Line Endings Before Carriage Returns

Dec 14, 2010

I have an some code to export data form an SQL database to an Excel spread sheet. the data is entered via a web site and some of it contains multiple lines of information. I need to preserve the multiple lines but excel 2007 continues to put an [?] at the end of each line.Here's what I got so far

CellValue.ToString() // this returns [?][?] at the end of each line for excel 2007
// and a single [?] in excel 2010
CellValue.Replace("[//r]","") // this works correctly for 2010 but still leaves a [?] for 2007
Cellvalue.Replace(Environment.NewLine, "") // this removes all the line breaks.

what can I replace the Environment.NewLine with in order to still have line breaks in both excel 2007 and 2010 (with no [?]) ?

View 2 Replies

Web Forms :: Is There A Way To Insert Carriage Returns And Tabs In The Text Property Of A Label

Jan 16, 2011

I have tried a number of ways to format the text of a label with codebhind, I don't get errors, but it just ignores the code.

For example, if I put label.text = "Some text " & chr(13) & "some more text"

it will just ignore the chr(13). I have tride vbcrlf, /n, etc.

I would rather not have to change the control to a text box but will if I have to.

View 4 Replies

Web Forms :: Adding Carriage Returns Between 2 Dynamically Created Controls In HtmlTableCell

Aug 24, 2010

[Code]....

On the line where i try and update the InnerHtml, i get the following error; "Cannot get inner content of because the contents are not literal."

View 2 Replies

Web Forms :: How To Access The HTML Control Values In Form Object, If Runat="server", Is Not Present In The HTML Controls

Mar 29, 2011

How to access the HTML control values in form object, if runat="server", is not present in the HTML controls.

View 6 Replies

How To Access To An HTML Control Runat Server From JavaScript

Jan 9, 2011

I have the following code:

[code]....

How to access to an HTML control runat server from JavaScript

View 1 Replies

Web Forms :: Add Runat Server To All Element In Html String

Dec 4, 2010

I have one html string in DB like below

<div style="padding-left: 200px; padding-top: 20px">
<div style="text-align: left;padding-top:10px">
<input id="Text1" type="text" /></div>
<div style="text-align: left;padding-top:10px">
<input id="Text2" type="text" /></div>
<div style="text-align: left; padding-top: 10px">
<input id="Button1" type="button" value="Submit" /></div>
</div>

i wan to render this in aspx page. but before this i want to all runat server to all html control in above string

like

<div style="padding-left: 200px; padding-top: 20px">
<div style="text-align: left;padding-top:10px">
<input id="Text1" runat="server" type="text" /></div>
<div style="text-align: left;padding-top:10px">
<input id="Text2" runat="server" type="text" /></div>
<div style="text-align: left; padding-top: 10px">
<input id="Button1" runat="server" type="button" value="Submit" /></div>
</div>

View 3 Replies

C# - Persisting Html Control Content With Runat Server Tag

Jan 11, 2011

I have this problem - I'm working on an ASP.NET AJAX-application on a server without .net 3.5 which means I can't use ListView (BOO!).

I decided to simply do the ugly way of making a table and giving the tbody an ID and a runat server tag, and put HtmlControls inside from the codebehind (btw - this is a usercontrol, in case it makes a difference).

This all works fine - until the page does a partial postback - and all the elements disappear, since the tag is runat server I assume it requires to be repopulated in the page load.

Is there no way to actually persist the data on partial postback? And only have the content of the control change when I say so in the back end?

I guess I could save the content in a session object upon populating the control, and just repopulate in the Page_Load with the session object - but I was hoping there was a better way to do this?

View 2 Replies

Web Forms :: WebControls Versus HTML Controls (with Runat=server)

Apr 14, 2010

I want to know differences between ASP.Net WebControls and Html Controls (with runat="server" attribute).

I also want to know the possible scenarios where I have to (or want to) prefer Html Controls (with runat=server) in place of asp.net server controls?

In case of some good articles on web, do forward me. But dont forward me the links with differences between webcontrols and html controls, because my question intended for runat="server" attribute.

View 8 Replies

JQuery :: How To Access Span From HTML To Codebehind Without Using Runat = Server Tag

Dec 7, 2010

I have a span control which I am filling using Jquery. At the page load I want this span say id1 to be invisible and depending on some conditions I am making it visible via jquery itself.

When I make id1 runat = server and try to access id1 from codebehing, then I get an error in Jquery.

Hence I need a way to make id1 invisble at the load time itself.

I have already set id1 = invisble in HTML, But still I see this control on the page till the time jquery fills the entire data.

View 4 Replies

Web Forms :: HTML Hidden Field With Runat Server Not Available In Code Behind

Jan 24, 2016

I am facing one asp.net server side issue using vb.net the problem is i declared one html input hidden field in my page, the name is hidden1. but when i going to call that name into server side code, that time i got the below error, <b>Name "Hidden1" is not declared</b> Code below:

Default.aspx
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="WebApplication2._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">

[code]....

View 1 Replies

HTML - Why Does Rewrite Relative Paths For Runat=server Anchor Controls

Mar 24, 2010

I have my UserControls in a ~/Controls folder in my solution:

/Controls/TheControl.ascx

If specify the following:

<a id="theId" runat="server" href="./?pg=1">link text</a>

ASP.Net seems to want to rewrite the path to point to the absolute location. For example, If the control is on [URL] the link href will be rewritten to read

<a id="munged_theId" href="../../Controls/?pg=1>link text</a>

Why does Asp.Net rewrite these control paths, and is there an elegant way to fix it?

I just want the anchor control to spit out exactly what I tell it to!!! Is that so hard?

EDIT:

I've basically done what Kelsey suggested. I knew I could do it this way, but I don't like adding markup in my code when I want something relatively simple. At least it solves the problem:

Aspx page:

<asp:PlaceHolder ID="ph" runat="server"></asp:PlaceHolder>

Code-behind:

var anchor = new HtmlGenericControl("a") { InnerText = "Previous" + " " + PageSize) };
anchor.Attributes["href"] = "?pg=" + (CurrentPage - 1);
anchor.Attributes["class"] = "prev button";
ph.Controls.Clear();
ph.Controls.Add(anchor);

As you can see by the amount of code needed for what is essentially supposed to be be a simple and light-weight anchor, it's not the most optimal solution. I know I could use a Literal but I figured this was cleaner as I'm adding more than one anchor.

View 4 Replies

Hide The HTML Control From The Server Side Without Using Attributes Runat="Server"

Sep 27, 2010

I am using HTML control,and want to visible false from the server side with out using attributes runat="Server"

View 2 Replies

HTML Agility Pack Removes Break Tag Close?

Apr 4, 2011

I am creating an HTML document using HTML agility pack. I load a template file then append content to it. All of this works, but when I view the output file it has removed the closing tag from my <br/> tags to look like this <br>. What is causing this?

Dim doc As New HtmlDocument()
doc.Load(Server.MapPath("Template.htm"))
Dim title As HtmlNode = doc.DocumentNode.SelectSingleNode("//title")
title.InnerHtml = title.InnerHtml & "CEU Classes"
Dim topContent As HtmlAgilityPack.HtmlNode = doc.GetElementbyId("topContent")
topContent.InnerHtml = html.ToString
doc.OptionWriteEmptyNodes = True
doc.Save(outputFileName, Encoding.UTF8)

More info:

It was removing my closing image tags, after I added doc.OptionWriteEmptyNodes = True, it quite doing that.

View 1 Replies

Web Forms :: Tag Cause Problem , It Removes Some Html Line On Webpage?

Nov 16, 2010

when I have <form> </form> tag on my .aspx page. then it cause some problem in page, for instance: I have header, which has one vertical line in it, but when I use form tage in page then all data is correct, but from the header it remove one verticle line.page with form tag in local environment (development environment) works fine, but when I move it to live then it creats problme.

View 1 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

Web Forms :: Remove Link In The Head Tag Of Html Page?

Jan 3, 2011

remove link in the head tag of html page

[Code]....

View 2 Replies

Inject Code Into Masterpage / Html Head From A User Control?

Jan 10, 2010

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?

View 4 Replies







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