3

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?

1
  • Please give some more info on your question. Its not clear Commented Jul 3, 2009 at 11:29

5 Answers 5

8

You can use LiteralControl to add HTML tags like that :

Page.Controls.Add(new LiteralControl("<p>New<br />Line</p>"));
Sign up to request clarification or add additional context in comments.

1 Comment

Note that this will just add the control to the page. If you want some control over where the literal will appear you can set the 'runat' property of a div. Then in your code behind use clientDivId.Controls.Add(new LiteralControl("html here"));
2

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>";

Comments

0

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.

Comments

0

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

Comments

0

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 );

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.