Using VB.NET in Visual Studio 2010, I have two files:
“test2.aspx” and “test2.aspx.vb”.
The aspx file is basically as follows:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="test2.aspx.vb" Inherits="App_test2" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta id="meta1" runat="server" name="description" />
</head>
<body>
<textarea id="text1" runat="server" />
</body>
</html>
The vb file is basically like this:
meta1.Attributes("charset") = "UTF-8"
meta1.Attributes("content") = "I'm a description tag"
text1.InnerText = "&'<>"
This all displays as expected in the browser, but the source code when the page is rendered looks like this:
<html>
<head>
<meta id="meta1" name="description" content="I'm a description tag" charset="UTF-8"></meta>
</head>
<body>
<textarea name="text1" id="text2">&'<></textarea>
</body>
</html>
Is there something I can do so the source code doesn’t escape characters like “&”, “‘”, “<“, and “>” ?
You don’t. If it didn’t convert those characters, the browser would incorrectly interpret them as commands instead of data. It shouldn’t be an issue for you because it is always converted back to the character data in code. text2.Text would contain the values you want, not the escaped data.