Showing posts with label Useing HTML tags in codebehind. Show all posts
Showing posts with label Useing HTML tags in codebehind. Show all posts

Friday, June 06, 2008

Useing HTML tags in C# or VB.Net codebehind

Its simple to use HTML tags in Code behind and display in ASP.NET web pages....

Method 1:

in .cs page

string t = txtBody.Text;
MyEmailBody.InnerHtml = Server.HtmlDecode(t);

in .aspx page

<div id="MyEmailBody" runat="server"></div>

It may some times require to change the ValidateRequest="false".

Method 2:

we can use Literal controls, to view HTML tags in .aspx pages from code behind.

in . aspx page

<asp:Literal runat="server"></asp:Literal>

in .cs page

this.Controls.Add(new LiteralControl("<b>This is Bold</b>"));

Hope this helps you in using HTML tags in codebehind.