国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > 綜合 > 正文

Page_Load事件

2024-07-21 02:26:04
字體:
供稿:網(wǎng)友

page_load事件---ispostback屬性

aspx代碼

 

<%@ page language="c#" autoeventwireup="true"  codefile="default.aspx.cs" inherits="_default" %>

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>無標(biāo)題頁</title>
</head>
<body>
    <form id="form1" runat="server">
    <div >
        <br />
        <br />
        <br />
        <br />
        &nbsp; &nbsp;&nbsp;
        <asp:label id="label1" runat="server" height="31px" text="用戶名:" width="95px"></asp:label>
        <asp:textbox id="textusername" runat="server" height="24px" ontextchanged="textusername_textchanged">textusername</asp:textbox><br />
        &nbsp; &nbsp; &nbsp;<asp:label id="label2" runat="server" height="29px" text="密碼:"
            width="93px"></asp:label>
        <asp:textbox id="textuserpwd" runat="server" height="22px">textuserpwd</asp:textbox>
        <br />
        <br />
        &nbsp; &nbsp;&nbsp;
        <asp:button id="btnlogin" runat="server" onclick="btnlogin_click" text="登錄" />
        &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
        <asp:button id="btnclear" runat="server" onclick="btnclear_click" text="清空" />
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        <asp:button id="btnclose" runat="server" text="關(guān)閉" /><br />
        <br />
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        <asp:label id="lblmessage" runat="server" height="66px" text=" " width="175px"></asp:label></div>
    </form>
</body>
</html>

aspx.cs代碼

 

using system;
using system.data;
using system.configuration;
using system.web;
using system.web.security;
using system.web.ui;
using system.web.ui.webcontrols;
using system.web.ui.webcontrols.webparts;
using system.web.ui.htmlcontrols;

public partial class _default : system.web.ui.page
{
    protected void page_load(object sender, eventargs e)
    {
        if (!page.ispostback) //判斷頁面是否是第一次加載
        {
            this.textusername.text= " ";  //將用戶名框設(shè)置為空
            this.textuserpwd.text= " ";  //將密碼框設(shè)置為空
        }
        this.btnclose.attributes.add("onclick", "window.close();");//關(guān)閉按紐設(shè)置,相當(dāng)于在aspx文件的asp:label中添加
    }

    protected void btnlogin_click(object sender, eventargs e)
    {
        if (this.textusername.text == "zuo" && this.textuserpwd.text == "zuo")
        {
            this.lblmessage.text = "登錄成功";
        }
        else
        {
            this.lblmessage.text = "登陸失敗";
        }
    }
    protected void btnclear_click(object sender, eventargs e)
    {
        this.textusername.text = " ";  //設(shè)置為空
        this.textuserpwd.text = " ";  //設(shè)置為空
    }
}

 

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 成都市| 敦化市| 建阳市| 台北市| 新乐市| 古浪县| 安福县| 绥德县| 大田县| 会同县| 台南市| 内江市| 罗山县| 全南县| 阿荣旗| 榆树市| 宁化县| 福贡县| 仙桃市| 九台市| 福海县| 开封县| 仲巴县| 龙泉市| 弋阳县| 忻城县| 铜梁县| 奇台县| 宁蒗| 广昌县| 舟山市| 长治县| 蒲江县| 南安市| 宝坻区| 桃江县| 武安市| 淮安市| 东莞市| 资溪县| 会同县|