第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定

用戶控件(UserControl) 使用事件 Ver2

標(biāo)簽:
JavaScript

把这些操作铵钮放在一个UserControl(用户控件)里,页面需要时,接进去即可。这个用户控件,可参考,每个Button分别设定CommandName和写同一个OnCommand事件。

5acf07320001405b00110016.jpgInsusUserControl.ascx <%@ Control Language="C#" AutoEventWireup="true" CodeFile="InsusUserControl.ascx.cs"
    Inherits="InsusUserControl" %>
<asp:Button ID="ButtonInsert" runat="server" Text="Insert" CommandName="Insert" OnCommand="Execute_Command" />
<asp:Button ID="ButtonEdit" runat="server" Text="Edit" CommandName="Edit" OnCommand="Execute_Command" />
<asp:Button ID="ButtonUpdate" runat="server" Text="Update" CommandName="Update" OnCommand="Execute_Command" />
<asp:Button ID="ButtonCancel" runat="server" Text="Cancel" CommandName="Cancel" OnCommand="Execute_Command" />
<asp:Button ID="ButtonDelete" runat="server" Text="Delete" CommandName="Delete" OnCommand="Execute_Command" />

 

InsusUserControl.ascx.cs:

5acf07320001405b00110016.jpgInsusUserControl.ascx.cs using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


public partial class InsusUserControl : System.Web.UI.UserControl
{  
    //宣告一个事件
    public event CommandEventHandler Execute;

    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Execute_Command(object sender, CommandEventArgs e)
    {
        if (Execute != null)
        {
            Execute(this, e);
        }
    }
}

 

下面是页面应用这个用户控件,在aspx在设计模式下,拉这个用户控件到页面中来,当然你也可以在aspx.cs内写代码动态添加:

Default.aspx:

5acf07320001405b00110016.jpgView Code <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register Src="InsusUserControl.ascx" TagName="InsusUserControl" TagPrefix="uc1" %>
<!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></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <uc1:InsusUserControl ID="InsusUserControl1" runat="server" />
    </div>
    </form>
</body>
</html>

 

Default.aspx.cs:

5acf07320001405b00110016.jpgView Code using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        this.InsusUserControl1.Execute += new CommandEventHandler(InsusUserControl1_Execute);
    }

    protected void Page_Load(object sender, EventArgs e)
    {
    }

    public void InsusUserControl1_Execute(object sender, CommandEventArgs e)
    {
        switch (e.CommandName)
        {
            case "Insert":
                ShowMessage(e.CommandName);
                break;
            case "Edit":
                ShowMessage(e.CommandName);
                break;
            case "Update":
                ShowMessage(e.CommandName);
                break;
            case "Cancel":
                ShowMessage(e.CommandName);
                break;
            case "Delete":
                ShowMessage(e.CommandName);
                break;
        }
    }

    private void ShowMessage(string buttonName)
    {
        Response.Write("你点击了" + buttonName + "铵钮。");
    }
}

 

點(diǎn)擊查看更多內(nèi)容
TA 點(diǎn)贊

若覺得本文不錯(cuò),就分享一下吧!

評論

作者其他優(yōu)質(zhì)文章

正在加載中
  • 推薦
  • 評論
  • 收藏
  • 共同學(xué)習(xí),寫下你的評論
感謝您的支持,我會繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進(jìn)行掃碼打賞哦
今天注冊有機(jī)會得

100積分直接送

付費(fèi)專欄免費(fèi)學(xué)

大額優(yōu)惠券免費(fèi)領(lǐng)

立即參與 放棄機(jī)會
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號

舉報(bào)

0/150
提交
取消