001. Set default values for input Type=text

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.