• 001. 为input type=text 时设置默认值


    1. 前端HTML代码

     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 <html xmlns="http://www.w3.org/1999/xhtml">
     6 <head runat="server">
     7     <title>HTML服务器控件</title>
     8     <script type="text/javascript" runat="server">
     9         //protected void Page_Load(Object sender, EventArgs e) //如果在当前页面设置Load事件, 那么.cs文件中的load的事件将会被覆盖
    10         //{
    11         //    this.MyText.Value = "hello world!"; //设置input的默认值
    12         //}
    13     </script>
    14     <style type="text/css">
    15         #MyText
    16         {
    17             width:188px;
    18             }
    19     </style>
    20 </head>
    21 <body>
    22     <form id="form1" runat="server">
    23     <input id="MyText" type="text" runat="server" />
    24     </form>
    25 </body>
    26 </html>

    2.下面是.cs中的load事件, 如果页面中有Page_load事件, 那么该事件将会被覆盖       (Page_load事件→页面初始化事件)

     1 using System;
     2 using System.Collections.Generic;
     3 using System.Web;
     4 using System.Web.UI;
     5 using System.Web.UI.WebControls;
     6 
     7 public partial class _Default : System.Web.UI.Page 
     8 {
     9     protected void Page_Load(object sender, EventArgs e)
    10     {
    11         if (!IsPostBack)
    12         {
    13             this.MyText.Value = "我是首次加载";
    14         }
    15         else
    16         {
    17             this.MyText.Value = "我不是首次加载";
    18         }
    19     }
    20 }
  • 相关阅读:
    [noip2011d2t2]聪明的质检员 二分+前缀和优化
    [noip2016d2t2]蚯蚓
    KMP
    杨辉三角(二项式定理)&&组合数 【noip 2011/2016 d2t1】
    bzoj1615 [Usaco2008 Mar]The Loathesome Hay Baler麻烦的干草打包机
    [noip2015 pjt3]求和
    [周记]8.28~9.3
    [noip2011 d1t3] Mayan游戏
    react基础用法二(组件渲染)
    react基础用法一(在标签中渲染元素)
  • 原文地址:https://www.cnblogs.com/wxylog/p/6030571.html
Copyright © 2020-2023  润新知