ASP Literal Or Page Altering HTML String Causes Formatting
Jun 16, 2010
We have a service that generates a report (using word templates and a 3rd party library), and then returns a string in HTML. While this HTML isn't great - its formatted correctly in this string. We want this HTML to show up on a page - format intact. What we currently have done is set an ASP.net Literal's text element to this string. While this works, I have noticed that it has reformatted the HTML string slightly. For the most part, it looks like it generated a bunch of new CSS classes, and a new style element in the HTML. This HTML does not exist in the string thats being returned. I could filter all of this back out, but wonder if there is a better way. I assume that the Page itself is altering something. What is the best way to display this raw HTML back to the user? I can't directly use a Response.Write(string), because this page does have a few other controls on it.
View 3 Replies
Similar Messages:
Feb 10, 2011
My user filled a textbox with a text that was copied from Microsoft Word. This is a part of the text .
This system is - AUTOMATIC - and it is restricted
Look the symbols before and after the word AUTOMATIC. When I try to write this on a dynamically generated html page using the code bellow, i got this on the screen:
This system is â€" AUTOMATIC â€" and it is restricted
Code used to print the SQL Field:
[Code]....
The - symbol is not a minus symbol, but is a Word minus (-) symbol...
I am using C#.NET and ASP.NET
View 3 Replies
Jan 28, 2011
I am fetching some data from Db and displaying it in a textarea using jquery in the following way.$('#textareatest').val('<% =teststring %>').It is possible that the string 'teststring' can contain XHTML line breaks(<br/>).whenever the string contains <br/> I am getting the 'unterminated string literal' error.I saw a number of posts considering '' as line breaks and suggesting to escape it.I tried to escape the <br/> similarly,but it didn't work.
View 4 Replies
Aug 23, 2010
I want to show just a part of a string for example:
Instead: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua."
Just a: "Lorem ipsum dolor sit amet, consetetur sadipscing..."
Which method can I use to do that?
View 3 Replies
Aug 10, 2010
Is there a way to disallow the asp:Literal from outputing HTML ?
If I input the text <b>Hello world</b> I want to show it just like that, and not in bold.
If possible I don't want to extend it, because I would have to change the whole project.
View 3 Replies
Sep 30, 2010
Can someone please tell me the difference and the advantages in these other than styling them? ```First option:
[Code]....
[Code]....
View 3 Replies
Aug 16, 2010
I'm trying to pass a string value to a javascript function from a LinkButton's OnClientClick event, but the function is receiving "<%# Container.DataItem %>" instead of the value. Here's the code:
OnClientClick="javascript:SaveQuotaGroupCode('<%# Container.DataItem %>');"
The container is a collection of strings. Why is it not evaluating?EDIT: This is located in a nested ListView. The datasource for the inner ListView is a property in the datasource of the outer ListView.
View 1 Replies
Nov 25, 2010
Here is my JavaScript:
<script type="text/javascript">
function onholdev(index) {
var chk = document.getElementById('<%=grdCons.Rows[' + index + '].FindControl
[code]...
View 3 Replies
Feb 26, 2010
recently i used literals inside HTML elements like so:
Code:
<div <asp:Literal ID="ltlpbEmpty" runat="server"></asp:Literal> align="left" <asp:Literal ID="ltlToolTip" runat="server"></asp:Literal>>
<div <asp:Literal ID="ltlPBFull" runat="server"></asp:Literal> <asp:Literal ID="ltlBarWidth" runat="server"></asp:Literal> align="left">
</div>
in this case both of this divs are part user control progress bar i'm making, from not related reason i couldn't use ASP.NET elements and had to go back to the traditional HTML elements.so to be able to give those elements dynamic attributes such as tooltip, id, class i had to add literals inside those elemtns..
View 15 Replies
Jan 17, 2010
My Problem Simply is when i create a Literal Control and I put at the text property Html Input
(<input type="text" name="textfield17" id="textfield17" />) and create an control button and But at the click event of the control button :
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Response.Write(Literal1.Text)
End Sub
and When I run the application I will find at the literal control a text box when i Type any text at it and click the button it return another Literal have only Html Input control without the text it entered
View 6 Replies
Jun 2, 2010
In order to generate clean markup, I often resort to using code similar to this:
<asp:Literal ID="ltItem" runat="server">
<li class="{0}"><a href="{1}">{2}</a></li></asp:Literal>
And in the codebehind:
[code]....
Therefore my question:
Is this a common way to generate clean markup? Are there better alternatives? Is the databinding syntax approach preferable?
View 1 Replies
Feb 24, 2011
I'm building a html table dynamically in an ASP.NET code behind file using C#. I basically loop through a set of data which is an unknown number of records and split a string containing all the values to make the required number of tds. I display the html by assigning it to an asp:Literal control. However I can't get the table to fit the screen - the browser is adding a horizontal scroll bar and the full table is well off the screen. I tried in IE 8 and FF 3.6.13. Most things I've read online about it say to set the width to 100%. I'm doing this but it's having no effect.
<div id="paging">
<asp:Button ID="btnPrev" runat="server" Text="Prev" CssClass="niceInput" onclick="btnPrev_Click" Enabled="False" />
<asp:Button ID="btnNext" runat="server" Text="Next" CssClass="niceInput" onclick="btnNext_Click" Enabled="False" />
[code]...
View 1 Replies
Jun 3, 2010
I am streaming HTML content into a Literal control in an ASPX page, and am continually running into a problem where the page loads fine the first time I try it, then subsequent attempts fail to load.
The purpose of the aspx page is to act as a 'broker' to another process that produces streamed HTML output, which then needs to be resolved by the browser.
The reason I'm not just using HtmlTextWriter to stream out the code to the Response object is that the streamed HTML contains framesets, and I am forbidden from modifying that code in any way, so I must keep the streamed code intact. In spite of the fact that frameset HTML hardcoded into the ASPX file would work, it does NOT resolve streamed frameset code!
In any case, streaming into the literal (by creating a string that is assigned to the Literal's Text property) works just fine -- the FIRST time I load that page. If I exit the page, then try to reinstantiate, it FAILS, producing an empty HTML file (containing only "<HTML></HTML>").
View 3 Replies
Jan 14, 2011
I've these codes in my DATABASE in other words it's HTML. I tried these stuff:
<div runat="server" id="div1" visible="false">
<asp:Literal ID="literal1" runat="server" Text="" />
</div>
I tried in C# code behind:
div1.InnerText = contents;
div1.InnerHtml = contents
literal1.Text = contents;
But is still doesn't render well. I displays the original values in stead of a table and cells and columns. colours etc. etc....
What am I missing?
All these HTML's are in DABASE.Column e.g. column "Contents"
e.g.
"& lt;p class=& quot;MsoNormal" style= "color: #339966;"><"
;" ;> ;< ;strong > ;&l
ot; > ;& ;nbsp; < ;/span >< ;/p >
I've put (spaces between & and gt above code otherwise it was not showing in stackoverflow.) The HTML sysntaxs are correct because it's created by an HTMLEDITOR.
View 2 Replies
Sep 23, 2010
I know that it is basic questions, but I am stuck here.
I have TableOne have fields: USERNAME, PID, GID, TID, SID, NEWSID. I need to write query string to check if those value is already in the table. If not, insert those value to the table.
[code]....
However, I got the many errors:
Error 1 Too many characters in character literal
Error 3 Newline in constant
View 3 Replies
Jan 7, 2011
I have the following code, which generates insert queries
For Each f As String In Directory.GetFiles(d)
objSQLStringBuilder.Append("insert into table1 (full_path, file_name) values ('" & f.Replace("'", "''") & "', '" & f.Remove(0, Len(d) + 1).Replace("'", "''") & "');")
Next
However, the paths which it finds are formatted as follows c:program filesmicrosoft officewinword.exe I need to format the paths as follows file:///c:/program%20files/microosoft%20office/winword.exe. How can I modify the above code to do this?
View 5 Replies
Apr 5, 2010
I've been wrestling with this for a while, and I just can't seem the get the correct amount of quotes in the correct place, so as a last resort, I'm hoping someone could attempt to correct it.
[Code]....
View 3 Replies
Mar 30, 2011
UPDATE 2:
In this section, I am trying to manually add in tabs and line spaces so the string is formatted when displayed via the pre tag. But this does not work.
objStringBuilder.Append("<div>" & Environment.NewLine)
objStringBuilder.Append(vbTab & "<div>some text</div>" & Environment.NewLine)
objStringBuilder.Append("</div>" & Environment.NewLine)
Return "<pre>" & Server.HtmlEncode(objStringBuilder.ToString) & "</pre>"
UPDATE 1:
I have tried the following, but it does not work:
return "<pre>" & Server.HtmlEncode("<div><div>some text</div></div>") & "</pre>"
I want it to display something like this
<div>
<div>some text</div>
</div>
But it's diplaying like this, which is expected:
<div><div>some text</div></div>
I don't know how to get spaces, tabs, carriage returns into that string which are recognizable by the pre tag, as environment.newline and/or vbtab make no difference.
ORIGINAL QUESTION:
Is it possible to display HTML as text on your page in a formatted manner? For example, it should contain white spaces, tabs etc etc for readability purposes:
From another question, I have learned how to display HTML as text as follows:
Server.HtmlEncode("<div>Some text</div>");
View 5 Replies
Jul 26, 2010
I have a calculation that takes place utilizing the TimeSpan.FromTicks method, the result is stored in a TimeSpan object. The calculation itself is working correctly, but I'd like to format the result a bit nicer than it is and I can't figure out how to format a TimeSpan.
The result from the TimeSpan is:
00:00:04.6153846
I'd like to remove any preceding zero's and round up to the second decimal place, such as:
4.62
Does anyone know how I might be able to accomplish this? I can't seem to find a .NET 'built in' solution.
View 1 Replies
Mar 4, 2010
DateTime.Now.ToString("h:mm tt")
What is the proper way to.. escape if that is the proper term, that html entity so that it will produce the output Code: 8:53 am and the non breaking space is rendered correctly be the browser?
View 1 Replies
Sep 23, 2010
I have a table in my SQL DB that is a DateTime table, what I want to do is take the numeric datetime it stores and convert it to a long date (i.e. 12/12/2012 conversts to December 12, 2012). Seaching the forums it looks like the string.format is the way to go and searching for info on that I found [URL] which lists all the different formats but they do not list a formating string to convert to the format I want to use. Does anyone know what format string I would use to convert a numeric date to a long date like I want? And can you show it in a code example because I am not 100% sure I understand the code examples shown on that site.
View 4 Replies
May 23, 2010
I insert into asp.net mvc views C# logic that manages layout like the following:
[code]....
I try to minimize <% %> code placing "{" symbol on the same line as it's condition (java-style). Html layout looks more clear to me after that.
Do you apply C# formatting rules to <% %> html injections "}" should be on a new line or manage layout in different way?
View 1 Replies
Jul 27, 2010
I am currently writing a small templating system in ASP.NET to allow users to add content. For example, the user can enter the string (variable type is string).
topHeader[x] = "They think it's all over. It is now!";
However, one change that's needed is the ability to add some basic HTML tags within this content, so the following can be done
topHeader[x] = "They think it's all over. <strong>It is now!</strong>" or
topHeader[x] = "They think it's all over. <a title="Football News" href="URL">It is now!</a>";
If you add such things into strings now they are not formatted as HTML, but I want to somehow escape them so that they can be. Naturally I've looked on the Internet for the answer, but as Razor is fairly new there's not much out there to help me out.
View 3 Replies
Feb 28, 2011
I've looked around and can't find a solution for this and it's driving me mad.I've got a basic MVC2 app (C#) and am trying to display text from a database with the line breaks included. I've used the following:
<p><label>Description:</label>
<span class="fieldBlock"><%: Model.Description.Replace(System.Environment.NewLine, "<br />") %></span>
</p>
This is adding the tags to the returned string as I'd expect but when the page renders it actually displays the tag as is instead of rendering the newline. ie. the text seen by the user in the browser is:"Quisque justo erat, iaculis sit amet aliquam eu, porttitor in mauris.<br /><br />Maecenas nisi velit, euismod at molestie vitae, malesuada id turpis. Mauris diam nisl, pretium id molestie nec, posuere posuere neque.<br /><br />Cras sed lectus nisl."
View 1 Replies
Aug 2, 2010
I have problem in converting date to string I am using cstr(p.tripstart) , which is returning Date as 12 Aug 2010 12:AM I need to make formating This is my code :
[Code]....
View 9 Replies