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
Similar Messages:
Jan 22, 2010
I'm trying to develope a collapsible panel control with designer.
I have the following two classes:
[Code]....
and this one:
[Code]....
In fact, the designer class is a copy of a sample class in MSDN and I only tried to customize it to work for me. I'm not sure if all methods are necessary or not.
I have the following two questions:
1- When I use this contrl in design mode, I can add or delete controls to it, in the html view, tags are not updated. so when I close the page and open it again, all changes are lost.
2- I have added this control to the same asp.net project that is using this control. Isn't there any way to have this controil in tool box?
View 5 Replies
Jul 20, 2010
i have view which display product list..this is how html looks like
<% foreach (var products in Model.Products) { %>
<ul id="<%: products.ProductID %>" class="">
<li>
<a href="">xx</a>
</li>
</ul>
<% } %>
This page will list 16 product items,means 4 by 4.MY question is,i need to set class value for in 1st,5th,9th and 13th ul tag.
smthing like this
<ul class="first"><ul><ul><ul>
<ul class="first"><ul><ul><ul>
<ul class="first"><ul><ul><ul>
<ul class="first"><ul><ul><ul>
how can do this with foreach...
View 2 Replies
Jan 13, 2011
I mainly do C# ASP.NET projects in VS2010. Once you've put masterpages and other things in place, I find the design view pretty much goes grey and elements can't be selected. This isn't so bad except that sometimes you need to access the little 'smart tags' at the top right of controls to do things.
In particular I'm trying to do this with some telerik controls, though the issue isn't confined to them.
Anyone have a handy tip to access this functionality (or miraculously make design view work!) ?
PS. I read in a few places that Shift-Alt-F10 may help. I tried putting my cursor in the control's tag and using it, no luck. Also I clicked the little rectangle below design view to select the control and tried it again- no luck.
View 1 Replies
Mar 12, 2010
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:
<content name="MainContent">
<!-- page specific csss -->
<link rel="stylesheet" href="/Content/css/page_specific.css" />
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.
View 1 Replies
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
Feb 8, 2011
I'm looking for a regex that will allow Alpha Numeric and most all special characters except white space. It should be usable in c#. It would be nice if .net supported posix style but I can't seem to get it to work.
View 1 Replies
Apr 7, 2010
I'm using an asp.net chart control to display a pie chart, image below.
[URL]
I can't find the property (I assume there must be a property) to get rid of the whitespace surrounding the chart. Does anyone know how to? I feel like I've tried everything...
View 1 Replies
Aug 1, 2010
I want to improve the html output by removing the whitespaces (see quora.com html output). There are a couple of "solutions" out there that do this at the Asp.Net level but those do not work reliable as they do not take the block buffering into account.
Anyone here who has a asp.net mvc 3 solution for that and is willing to share?
View 10 Replies
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
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
Sep 27, 2010
"something here [tagQuote=Name of Author]bla bla bla[/tagQuote] something here"And now I want to replace all the whitespace character in quote attribute with "%#%#%#%".So I want to have: [tagQuote=Name%#%#%#%of%#%#%#%Author]bla bla bla[/tagQuote]So remove all of the whitespaces between "[tagQuote=" and "]...[/tagQuote]"
View 3 Replies
Jul 23, 2010
I'm using the following codeproject to build an asp.net website and so far everything is good. My only problem is after the barcode is generated, a huge whitespace exist to the right of the barcode. I've been playing with this and am unable to resolve it.
Details below:
Link to Code Project Article: [URL]
Copy of the Font is here: [URL]
//Working Path
string sWorkPath = "";
sWorkPath = this.Context.Server.MapPath("");
//Fonts................
View 1 Replies
Feb 27, 2011
Not too sure if the title is the most appropriate description, but I've noticed at the bottom of my page I have a load of 'whitespace' / emptiness where my panel - that is linked to ModalPopup - is during coding / design. Is there a way of this space not appearing when the page is rendered? Setting the panel's visibility to false gives me all sorts of issues and I don't know where to go now to get rid of this annoying space!
View 2 Replies
Jan 20, 2010
I am accumulating a string for a SQL IN clause, so the format needs to be WHERE var IN ('string1','string2','string3',etc)
The strings are coming from a multiline textbox where they are pasted in from the user (one per line).
For some reason, I always get a space right after the tick and before the value in every value after the first. For instance my DataReader is only returning one record because the input string turns out like this:
SELECT * FROM Table
WHERE ID IN ('12345',' 23456',' 34567')
Here is how I am processing the string, and I can't see why it is not taking that space out.
[Code]....
Even if I move the replace space (line 2) to the end of the code block, it still wont trim it out...
View 3 Replies
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
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
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
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
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
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
Feb 10, 2010
a)i have an gridview, i need to every record show in every rows, but it's show in both column and rows...., how fix this?i use only itemTemplate in this gridview!
b)how i link a field thats show in gridview and pass to a new page(with query string) for show single record....?
(this is like "read more..." link in many news site!!!)
c)in my db is a 'ntext' field,but when that show in Gridview,all enter(Chr13) and whitespace deleted, how fix this?
View 5 Replies
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
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
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