How to add controls dynamically when click button in asp.net?

前端 未结 3 1310
没有蜡笔的小新
没有蜡笔的小新 2020-12-18 03:36

I\'m trying to add controls dynamically

Code:

AddVisaControl.ascx

<%@ Control Language=\"C#\" AutoEventWireup=\"true\" CodeBehind=\"AddVi         


        
3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-18 04:07

    Remove static int i = 0;

    Change the method as below

      protected void addnewtext_Click(object sender, EventArgs e)
        {     
    
                AddVisaControl ac = (AddVisaControl)Page.LoadControl("AddVisaControl.ascx");
                PlaceHolder1.Controls.Add(ac);
                PlaceHolder1.Controls.Add(new LiteralControl("
    ")); }

提交回复
热议问题