To enable the asp.net application to have custom space for users, for example, if you want to use a custom style sheet or title for the page, you can use the following method to dynamically specify it:
First, modify the title and style sheet of the <HEAD> In the ASPX file.
Code generated by Visual Studio:
<Title> WebForm1 </Title>
<LINK ref = "stylesheet" type = "text/css" href = "control.css">
Modified code:
<Title runat = "server" id = "Title1"> WebForm1 </title>
<LINK id = "link1" runat = "server" type = text/css "ref =" stylesheet "> </link>
We add runat = server to both HTML elements and mark them as server-side controls so that we can access them in the server code.
In the WebForm1.aspx. cs file, we can use the C # code to control the row.
Private void button#click (object sender, System. EventArgs e)
{
Control ctrl = Page. FindControl ("Title1"); // search for the Title we modified to runat = server.
(HtmlGenericControl) ctrl). InnerText = "Hello ";
Ctrl = Page. FindControl ("link1 ");
(HtmlGenericControl) ctrl). Attributes. Add ("href", "control.css ");
}
The above steps can be used to dynamically change the title of the ASP.net page and dynamically specify the page style table.