Prevent From Encoding Strings On Output?
May 11, 2010
How can I stop ASP.Net from encoding anchor tags in List Items when the page renders?I have a collection of objects. Each object has a link property. I did a foreach and tried to output the links in a BulletedList, but ASP encoded all the links.Here's the offending snippet of code. When the user picks a specialty, I use the SelectedIndexChange event to clear and add links to the BulletedList:
if (SpecialtyList.SelectedIndex > 0)
{
PhysicianLinks.Items.Clear();
[code]...
View 3 Replies
Similar Messages:
Jan 26, 2011
I would like to make sure that everything that goes into my database is safe, i.e. protection from sql injection.
What I want to do is type something in a textbox, "<b>hello</b>" for example, it be encoded before it's put in the database, but when I retrieve it, I want it to display "hello" in bold.
I've tried the obvious of server.encode on input and server.decode on the output (to a label and a literal control), but couldn't get it to display the text in bold without having unencoded text in the database.
View 7 Replies
Jan 13, 2011
I am starting work on an already fully developed site. This site has no input encoding or output encoding. If some one ebters <input type="text"> in an insert form it is displayed as a real tex box when viewing that form details.
So how can i apply encoding at input or output to the WHOLE SITE?
turning on validate request is not an option as the cms wud need it off.
also this is .net 3.5 so no question od using <%: tags.
View 4 Replies
Jan 30, 2010
I have a GridView bound to a DataTable that I construct. Most columns in the table contain the raw HTML for a hypelinklink, and I would like that HTML to render as a link in the browser, but the GridView is automatically encoding the HTML, so it renders as markup.
How can I avoid this without explicitly adding HyperLink, or any other, columns?
View 3 Replies
Oct 27, 2010
It's great that Razor HTML encodes by default. However, many times I have HTML in a database and want to display it literally on a page. In WebForms 4, we can use <%= %> and <%: %> to choose between encoding options. Raven's syntax is currently @(new HtmlString(Model.Greeting)).
add a shorter syntax to Razor. Something like @=Model.Greeting or @@Model.Greeting, or something else.
View 7 Replies
Jan 4, 2010
I have written a web mailer that can send and receive emails and display them on a webpage.I have a problem displaying special characters though. Like Russian, and Greek and chinese.I am using openpop.net and I can get the encoding of the incoming email as one of my variables.Thing is, how do I display it? Do I set the content encoding of the whole page to what that specific email encoding is?I've got it UTF-8 at the moment and I get garbage.
View 3 Replies
Jan 5, 2010
Im pulling out a text field from the database which has and 's in it for line breaks. Which I have left there for pupose of being able to edit the fields later on.
So when i try to display the text I need to replace them which I have done with:
[Code]....
Simple enough. Only when I run the page the source code I get for it is:
<br />
So it seems its not encoding the < as a encode but into the form <
Does anyone know how to stop this happen. Or a method around it?
View 3 Replies
Apr 18, 2010
First off, suggest better ways if you want rather than patch up this code. I am just starting this project and it is first time I have tried to code a web site so anything you suggest is very much welcomed. I have spent the last 2 and 1/2 days trying to find workable answers to this but none I have found and tried seem to fit. If needed I can email screens shots or code. I am trying to construct a website that will have the same main theme throughout as far as the header, navbars sitemap, and footer go. Naturally the content will vary from page to page. I want to use a single master page and css stylesheet for this main theme and I will change the content format as needed per page because each page may vary somewhat.
However, about 15 of the pages will all use the same format for their content and this format will differ from the rest of the site but the format of the main theme will stay the same. So I am trying to create a nested master page to use to format the just the content area for all these pages while retaining the main theme for the header, etc.. I believe I should use a separate css file with the nested master page to handle the formatting of the content areas for these 15 pages. I have code that looks like it works when viewed in web developer but design view but does not work when viewd through a browser (IE, Chrome, Firefox). So far I have the following done in web developer.
If it helps the code and screen shots follow. Master Page called "Parent.master". For all theme throughout site Nested Master Page called "Lab.master". For the 15 like pages Primary stylesheet file for main theme called "StylesheetNew.css" For site theme Secondary stylesheet file to syle the 15 like formatted pages. It is called Labmaster.css Labs.apsx file to use as first of the 15 like pages.
Finally screens shots from web developer and browser. Sorry try as I might I could not capture screenshots and put them into this post. The problem is that web developer shows all the area (many lines high) with gray background and with the XXX text that I want to allocate for content in the 15 pages. Yet all the browser show is one line of text o a white background followed by the footer. It looks like the LabStyleSheet works in Web Developer but not in a browser.
Parent.master
<%@ Master Language="VB" CodeFile="Parent.master.vb" Inherits="MasterPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL]">
<html xmlns="[URL]">
<head id="ParentHeader" runat="server">
<title>HX5</title>
<asp:ContentPlaceHolder runat="server" id="headerPlaceHolder" />
<link href="~/StyleSheetNew.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div id="wrapper" >
<div id="Header" >
<table class="hdrtbl1" >
<tr>
<td id="hdrtd1" style="width:175px; height:100px;" >
<img id="logo" alt="Logo" src="../Images/logo.png" style="width: 136px; height: 87px" />
</td>
</tr>
</table >
<table class="hdrtbl2" >
<tr><td id="hdrtbl2td1"><b> Providing Professional Technical, Manangement and Business Solution</b></td></tr>
<tr><td id="hdrtbl2td2"> <b> Services since 2004 </b></td></tr>
<tr> <td id="hdrtbl2td3" align="center" ><img id="rdln" alt="RedLine" style=" height:3px;" src="../Images/RedLine.png" /></td></tr>
<tr><td id="hdrtbl2td4" > <b>Committed to Excellence In All We Do</b></td></tr>
</table>
</div>
<div id="navbardiv">
<ul id="topnav">
<li><a href="../pages/about.aspx" >About Us <img style=" border: none; " src="../Images/arrow-down.gif" /></a>
<!--Subnav Starts Here-->
<span>
<a style="font-weight:lighter; " href="#" >Who We Are </a> |
<a href="#">Locations</a> |
<a href="#">Business Classifications</a> |
<a href="#">Contact Us</a> |
</span>
</li>
<!--Subnav Ends Here-->
<li><a href="../pages/services.aspx">Services <img alt="arrow" style="border: none; " src="../Images/arrow-down.gif" /></a>
<!--Subnav Starts Here-->
<span>
<a style="font-weight:lighter; " href="#" >Capabilities</a> |
</span>
<!--Subnav Ends Here-->
</li>
<li><a href="#">Customers <img style=" border: none; " src="../Images/arrow-down.gif" /></a>
<span>
<a style="font-weight:lighter; " href="#" >Subnav Link</a> |
<a href="#">Customer Locations</a> |
<a href="../pages/labs.aspx">Labs</a> |
</span>
</li>
<li><a href="#">Careers <img style=" border: none; " src="../Images/arrow-down.gif" /></a>
<!--Subnav Starts Here-->
<span>
<a style="font-weight:lighter; " href="#" >Joining the HX5 Team</a> |
<a href="#">Current Opportunities</a> |
</span>
</li>
</ul>
</div>
<div id="subnavbar" >
<!-- <asp:SiteMapPath ID="SiteMapPath" runat="server">
</asp:SiteMapPath> -->
</div>
<div id="topContent" style="border-bottom:solid 1px #191970;">
<table>
<tr><td style="height:30px; width:900px;" >
<asp:ContentPlaceHolder id="TopPlaceHolder" runat="server">
</asp:ContentPlaceHolder>
</td>
</tr>
</table>
</div>
<!-- <div id="mainContent"> -->
<asp:ContentPlaceHolder id="MainPlaceHolder" runat="server" />
<!-- </div> -->
<!-- <div id="lowerContent"> -->
<asp:ContentPlaceHolder id="LowerPlaceHolder" runat="server">
</asp:ContentPlaceHolder>
<!-- </div> -->
<div id="footerContent" style=" height:50px; width:900px; text-align: right; background-color: #ccc; ">
<span style=" font-family: Arial, Helvetica, sans-serif; font-size: xx-small; font-weight: bold; color: #000080; margin: 30px 20px 0px 0px;"> Copyright 2010 HX5, LLC All rights reserved</span></div>
</div>
</form>
</body>
</html>
View 4 Replies
Dec 16, 2010
What's better in ASP.NET MVC
<%= Html.LabelForModel() %>
or
<%: Html.LabelForModel() %>
View 4 Replies
Sep 16, 2010
I have a url that I would like to put into my web.config file. http://google.com?parcel&bob&&smithI imagine that the .net run time is upset with the ampersand's so i encoded them to be&.http://google.com?rcel&bob&&smithThis also doesn't work. Any ideas would be great, if you could supply a link to the documentation of why this is that would be even better.
View 3 Replies
Dec 10, 2010
I am using ASP.NET 4 c# 2010.Well my website has some problem with character encoding.It seems that when I generate my output it is htmlencoded. So a ' is encoded with #number;... this is not always a good thing because when I need to dynamically insert jscript in my controls, every ' or " are encoded and js doesn't work properly...
How to correctly tell ASP.NET not to encode? or better telling him that he must correctly manage ' " and other chars like these withput rendering them htmlencoded?
An example of string being output: this.MyControl.Attributes["onfocus"] = "execJs('param')"
well it results so:
<textarea id=".." onfocus="execJs('param')">...
This is not correct.
View 1 Replies
Jan 18, 2010
Can someone lead me to understanding when to set the encoding for the email step when sending new member emails. For instance what is the default or how can I tell what it is or if I want to set it in the SendMail event in code. See the thing I am wondering is when is it applied? If I set the MailDefinition-From in the html part then in code using the SendMail event set the encoding using
e.Message.From = new
MailAddress("foo@bar.com","foo",System.Text.Encoding.UTF8);
then I assume that it must actually get applied when the email is sent. Is that correct?
View 1 Replies
Dec 11, 2010
I'm developing a small ASP.NET Mvc project in Mono 2.4, Ubuntu 10.10. There is an array of objects, each one of them corresponds to a certain xml file. Reading of the xmls is performed with XmlTextReader. That does not work because xml files have rare "cp866nav" encoding, which is not supported by XmlTextReader ("System.ArgumentException: Encoding name 'cp866nav' not supported"). But it works fine if encoding in xml header is changed to "cp866". I found a kind of solution which consists in initializing XmlTextReader with a StreamReader with a certain encoding instead of file name, like in the code below:
XmlTextReader reader = new XmlTextReader(new StreamReader(Server.MapPath(filename), Encoding.GetEncoding("cp866")));
The issue is that the directory which contains xml files is read only (I can not change it), so I get "System.UnauthorizedAccessException: Access to the path '' is denied.". Rather strange, because XmlTextReader initialized with a filename seems to read the files. Is there any solution, considering that program cannot modify or create files?
View 1 Replies
May 6, 2010
I have a problem in my asp.net 3.5 application (C#) when I try to render in my pages characters like 'è' which are shown in a very strange manner (if i'm lucky i get a ? mark in my web page). in fact Expression Web, when i open my web site, substitutes the è char with �...How can I tell asp.net that I want to use a particular charset so that i can write in the html source letters like è without using hexadecimal codes??????I tried in the web.config this:inside the system.web namespace of the file but nothing works...
View 1 Replies
Mar 8, 2010
I have an ASP.Net app that allows a user to write text into a Telerik RadEditor control and then send an email.
For some reason I'm sometimes getting strange characters showing up in the email that is generated.
For example if I put the word Test's into the RadEditor box and send it... the email shows up with the text changed to: Test’s.
It seems as though the ' character was used in place of ' because if I use the later, the text would show up just fine. If I pull up the saved record within the ASP.Net apps interface it looks just fine. It also appears just fine when I view the text within the recorded of the MS SQL table it was stored in.
I'm using MailMessage to create the email. I've check the string being sent at the point just before I use SmtpClient to send the message and it looks just fine at his point. Once the email message shows up however I get the strange text (Test’s).
I'm guessing that I have an encode/decoding issue but I'm not sure how I would go about fixing this.
Continued--->
I have tried to add it to the constructor of my email class with/without mybase but that had no effect.
Public Sub New(ByVal EmailDate As DateTime, ByVal LogoPath As String)
MyBase.New()
MyBase.BodyEncoding = Encoding.GetEncoding("iso-8859-1")
'BodyEncoding = Encoding.GetEncoding("iso-8859-1")
Me.EmailDate = EmailDate
Me.LogoPath = LogoPath
End Sub
I also tried adding it to the code behind of the form that calls the email class just before I create a new SmtpClient but that did not seem to be correct either.
Try
returnEmail.BodyEncoding = Encoding.GetEncoding("iso-8859-1")
Dim smtpCli As New SmtpClient
smtpCli.Send(returnEmail)
Catch ex As Exception
ScriptManager.RegisterStartupScript(Me, Me.GetType, "smtpError", "alert('There was an error sending the email:
* " & ex.Message & "');", True)
End Try
View 2 Replies
Feb 21, 2011
I have a website on live server, and I have a the same website on local machine. both using the same database. Some links are in Arabic.
The links are ok on live server, but it is corruptted on local machine.
Both Live server and local machione are hosting the website using IIS 7.
I think that the only chance is related to IIS configuration but how??
View 1 Replies
May 4, 2010
.Net 4.0 is encoding values when using Attributes.Add. In previous versions it didn't. With the new behaviour it is no longer possible to write attributes containing single quotes.Here's an example.
<asp:TextBox ID="txtTest" runat="server" />
txtTest.Attributes.Add("onkeyup", "keyuphandler('hello')");
With the application pool framework version set to 2.0 it produces the desired result:
<input name="txtTest"
type="text" id="txtTest"
onkeyup="keyuphandler('hello')" />
With it set to 4.0 it produces an undesirable result:
<input name="txtTest"
type="text" id="txtTest"
onkeyup="keyuphandler('hello')" />
.Net 4.0 needs to be fixed to allow the developer to write attribute values containing single quotes.
View 9 Replies
Dec 22, 2010
I have an ASP.NET repeater pulling comment data from a database. In my ItemTemplate I placed some Label server controls bound to the fields (username of poster, date, and post text), but apparently Label does not run the data through HtmlEncode before displaying it. Is there another control I should use? How should I display HTML-encoded data from a repeater?
View 3 Replies
Jan 28, 2011
I am using .NET Page Routing (not MVC) to get pretty URLs (or at least removing the file extensions) on my site.On my search page, when a user searches for "stuff" it redirects then to /search/stuff for the results. However when I put in something like "stuff yes:" it gives me a HTTP 400 Bad Request Error.
I tried using javascript to encode the search value before being submitted, and confirmed that "stuff yes:" was converted to "staff%20yes%3A", yet when it performs the routing redirect, in the URL it shows "staff%20yes:" and causes the bad request. Why is it not saving the encoding for the typically illegal characters and how can I make it so?
View 1 Replies
Feb 22, 2011
I've recently upgraded a client's web site to .NET 4 and we've found out during the process that now GridView column values are automatically HTML encoded.
They have wide use of HTML strings in their code so we must turn that off. I know one solution would go over each column and add HtmlEncode="false". My question is - is there a way to set this to be the default for all GridView columns in this application?
View 2 Replies
Dec 26, 2012
What is happening is I'm trying to process international characters, but the code is falling through (giving up?) and replacing the field with a blank (well, I guess the screenshot is at the bottom)... The customer recently asked for support for Polish characters, and gave us a list of which ones he wants added.
This is the entire function:
Code:
Protected Function chkExtchars(ByVal name As String) As String
Dim j As Integer = 0
Dim dt As New DataTable
Dim c() As Char = Nothing
Dim n As Integer
Dim nc As Char
Dim newname As String = ""
dt = HttpContext.Current.Session("xChars")
[Code] ....
But maybe it needs to be sequential? (the numbers on the far left?)
View 3 Replies
Mar 30, 2011
I have a stored procedure that works fine for classic asp, but how can I get my output parameters data back from in /MVC 2 / linq/ entities framework model . I have inported the function also, but when i try to code it i dont get results ...i know this is a matter of lack of / knowledge or exmple because i have been scouring the web for it and cannnot find into that accually works.
here is the stored proc.
[Code]....
Here was the one of the few tries I did:
[Code]....
but it executes fine does not give me an error, but also does not return the info i need to the viewmodel
I keep seeing stuff about "ref" on the net but "ref" shows " arbument # should not be passed with the ref keyword.
So i am not sure if there is a problem with the model, or with my understanding this, Now for your info I can do the same step with returning a dataset from a stored procedure fine, but I dont want a data set I just want excatly the data in the output parameters from the stored procedure.
View 2 Replies
Dec 27, 2010
Our problem is the following:
We have a website that processing products from various web shops! Users of these web shops can send products for our site what will store these products in our database. Users are sending in products through the post method of the form, and within the form the data is in hidden imput fields! Our site using UTF-8 charset, and this service is working like a charm together with other pages that has utf8 chaset too. The problem comes when someone using our service from a site that has other charset then utf8, for example: iso-8859-2.This case the special hungarian characters, like "Ãéáűőúöüó" are replaced with a '�' character!We have tried to convert the incoming string on server side but that case the '�' has been replaced by '?'. - still not acceptable :)
View 1 Replies
Feb 21, 2010
What is ViewState? How is it encoded? Is it encrypted? Who uses ViewState?
View 5 Replies
Jan 14, 2011
I'm storing some html-encoded data in a sql server database and I've written a script to output the data in a csv format minus the html tags and I'm getting a weird issue when html-decoding the remaining data. For example the data contains a quote character (which is html-encoded as ’), but when I try to html-decode it the data comes out as a series of weird characters (’). Does anyone know how to solve this issue? The output encoding of the page is UTF-8 if that helps.
View 2 Replies