Dynamically change custom components!

zhaozj2021-02-16  131

1, put a container Placeholder on the leaves

2, you can dynamically load the required custom components, or user components

Example:

A TextBox is loaded now, then the return is changed to Button.

code show as below:

protected System.Web.UI.WebControls.PlaceHolder PlaceHolder1; protected System.Web.UI.WebControls.Button Button1; (! IsPostBack) private void Page_Load (object sender, System.EventArgs e) {if {TextBox t = new TextBox () ; T.Text = "First loading"; PlaceHolder1.controls.add (t);}} private void button1_click (object sender, system.eventargs e) {PlaceHolder1.controls.clear (); button b = new button ( ); B.Text = "Heart Rain Building"; PlaceHolder1.Controls.Add (b);}

Running effect: the first time IXTBOX

Click the button to change

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

New Post(0)