1. Front-end HTML code
1 <%@ Page Language="C #"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_default" %>2 3 <!DOCTYPE HTML Public "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd ">4 5 <HTMLxmlns= "http://www.w3.org/1999/xhtml">6 <Headrunat= "Server">7 <title>HTML server Controls</title>8 <Scripttype= "Text/javascript"runat= "Server">9 //protected void Page_Load (Object sender, EventArgs e)//If the Load event is set on the current page, the Load event in the. cs file will be overwrittenTen //{ One //This . Mytext.value = "Hello world!"; Set the default value for input A //} - </Script> - <styletype= "Text/css"> the #MyText - { - width:188px; - } + </style> - </Head> + <Body> A <formID= "Form1"runat= "Server"> at <inputID= "MyText"type= "text"runat= "Server" /> - </form> - </Body> - </HTML>
2. The following is the load event in. cs, which will be overwritten if there is a Page_Load event on the page (Page_Load event → page initialization event)
1 usingSystem;2 usingSystem.Collections.Generic;3 usingsystem.web;4 usingSystem.Web.UI;5 usingSystem.Web.UI.WebControls;6 7 Public Partial class_default:system.web.ui.page8 {9 protected voidPage_Load (Objectsender, EventArgs e)Ten { One if(!IsPostBack) A { - This. Mytext.value ="I was the first to load"; - } the Else - { - This. Mytext.value ="I'm not the first to load"; - } + } -}
001. Set default values for input Type=text