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

I would like to add a few paragraphs or new lines or words dynamically, but I want to make spaces between each part and the other. How can this be done on a C # code page?

+3
source share
5 answers

You can use LiteralControl to add HTML tags:

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

I was able to do this with lblMessage.Text, and then replaced the character with the "character 'in the HTML code ...

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

. , HTML <p> . , .

0

You can do this using the HttpModule . The HttpModule can intercept the request and respond and modify as necessary.

0
source

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

So, if you want to add a paragraph with a break inside:

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

Source: https://habr.com/ru/post/1711807/


All Articles