Ahmad Farid
Ahmad Farid

Reputation: 14774

Write html code inside asp.net (C#) (.cs) page

I would like to add some paragraphs or new lines or words dynamically but I want to make gaps between every part and the other. How is it possible to do that in the c# code page?

Upvotes: 3

Views: 23909

Answers (5)

Useful_Info
Useful_Info

Reputation: 21

I was able to do it using lblMessage.Text and then replacing the " character by the ' character in the HTML code...

lblMessage.Text = "<a href='javascript:history.go(-1)'>Go Back</a>";

Upvotes: 2

misnyo
misnyo

Reputation: 1767

Maybe this is the proper way: http://msdn.microsoft.com/en-us/library/620b4fzf(VS.71).aspx

So if you like to add what a paragraph with a break inside:

HtmlGenericControl paragraph = new HtmlGenericControl("p");
paragraph.Controls.Add(new HtmlGenericControl("br"));
Page.Controls.Add(paragraph );

Upvotes: 0

this. __curious_geek
this. __curious_geek

Reputation: 43217

You can do this using HttpModule. HttpModule can intercept request and response and modify as you need.

Upvotes: 0

Daan
Daan

Reputation: 6994

Ideally, you don't want to add markup code to your codebehind pages. But if you must, you can perhaps use HTML's <p> element to make different paragraphs. By default, each paragraph has some top and bottom margin to separate it from other elements on the page.

Upvotes: 0

Canavar
Canavar

Reputation: 48098

You can use LiteralControl to add HTML tags like that :

Page.Controls.Add(new LiteralControl("<p>New<br />Line</p>"));

Upvotes: 8

Related Questions