Asp. NET provides us with a control class: System.Web.UI.HtmlControls.HtmlGenericControl. It can implement an instance of an HTML element, such as controlling the <td> element in ASPX in the. CS code (note that it is not <ASP:TableCell>). We know that the title of the page is contained in <TITLE></TITLE>, and that <TITLE> is also an element of HTML, so We can use System.Web.UI.HtmlControls.HtmlGenericControl to control <TITLE>.
Asp. NET, If you want to be in. cs controls an element of ASPX (whether the element is a Web control or an HTML control), the Runat property of the element must be set to server, that is, only the element's Runat property is set to server, and the element can be controlled in. CS (of course, this element must be set ID's).
 
Now let's try, in the HTML code for the ASPX file, change the <TITLE> element to:
 
 
  
  Copy Code code as follows: 
 
 
  
 
  
  
<title runat= "Server" id= "Titlecontrol" >default title</title> 
  
 
 
 
  
Note Be sure to set the runat= "server" and ID (ID is important and note case). The default title here is the defaults, and when you do not change the title, it displays default title. 
Go to the. cs file, declare a variable Titlecontrol, type System.Web.UI.HtmlControls.HtmlGenericControl: 
 
 
  
  Copy Code code as follows: 
 
 
  
 
  
  
protected System.Web.UI.HtmlControls.HtmlGenericControl Titlecontrol; 
  
 
 
 
  
In this way, Titlecontrol is the <TITLE>. To change the title, you can add in the. cs method (for example: Page_Load): 
 
titlecontrol.innertext= "I changed the title!" ”;
 
In fact, the System.Web.UI.HtmlControls.HtmlGenericControl control can be the performance of all HTML controls on the server side, that is to say, just in the background code (. Aspx.cs/.aspx.vb) You can declare a System.Web.UI.HtmlControls.HtmlGenericControl control object that is the same as the HTML control ID on the front end, and note that the HTML control's properties in the front-end include a runat= "server". Otherwise, the background code does not perform operations on the front-end HTML controls.
 
You can also add the literal control between <title></title>, the effect is the same!