Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Add Text Dynamically in Head Section in asp.net

Tags:

c#

asp.net

I want to add the server name in my page head section dynamically like

<head>
<!-- DP2-WEB005 -->
</head>

can anyone please let me know how can I add this <!-- DP2-WEB005 --> tag in head section.

server name I will handle it but I don't know how add that commented tag dynamically.

like image 811
Dhaval Patel Avatar asked Feb 13 '23 20:02

Dhaval Patel


1 Answers

HtmlGenericControl newControl = new HtmlGenericControl("someTag");
newControl.Attributes["someAttr"] = "some value";
Page.Header.Controls.Add(newControl);

I hope this helps ... (the reference)

UPDATE:

This is that you want :

string serverName = "QWERTY123";
this.Page.Header.Controls.Add(new LiteralControl("<!-- " + serverName + "-->"));

And here is the output :

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>

</title><!-- QWERTY123--></head>
like image 136
Saman Gholami Avatar answered Feb 15 '23 11:02

Saman Gholami