Dynamically add ASP.NET controls and bind to process events

xiaoxiao2021-03-05  28

Private Void Page_Load (Object Sender, System.EventArgs E)

{

Control C3 = parseControl ("");

Control C4 = PARSECONTROL ("");

PlaceHolder2.controls.add (c3);

PlaceHolder2.controls.add (C4);

Button mybut = (button) Page.FindControl ("Button3");

MyBut.command = New CommandeventHandler (this.onbutton);

Button mybut2 = (button) Page.FindControl ("Button4");

Mybut2.command = New CommandeventHandler (this.onbutton);

}

Public void Onbutton (Object Sender, CommandeventAndAndeventargs E) {Switch (E.Commandargument.toT7tring (). TOLOWER ()) {CASE "B0": label1.text = "Button 0"; Break; Case "B1": label1.text = "Button 1"; Break; Case "B3": label1.text = "Button 3"; Break; Case "B4": label1.text = "Button 4"; Break;};

转载请注明原文地址:https://www.9cbs.com/read-33409.html

New Post(0)