the control want use registered in page.
<%@ register src="~/medcontrols/statform.ascx" tagprefix="uc1" tagname="statform" %>
and displaying in page using code. (using different id's && different temphosp#)
<uc1:statform runat="server" temphospnum="er101" id="statform1" /> <uc1:statform runat="server" temphospnum="er102" id="statform2" /> <uc1:statform runat="server" temphospnum="er103" id="statform3" />
now need is, on click button event, create new user control, same user control different id , different property eg.
edit
protected sub btnaddusercontrol_click(sender object, e eventargs) handles btnaddusercontrol.click 'generate user control temphospnum = "er104" , id="statform4" end sub
now adding in page.init only, not on button_click
'not working protected sub btnnewbed_click(sender object, e eventargs) handles btnnewbed.click dim mycontrol statform = page.loadcontrol("~/medcontrols/statform.ascx") mycontrol.id = "statform13" mycontrol.temphospnum = "er113" mycontrol.erbednumber = "bed13" form1.controls.add(mycontrol) mycontrol.visible = true end sub 'this working not needed protected sub page_init(sender object, e eventargs) handles me.init dim mycontrol statform = page.loadcontrol("~/medcontrols/statform.ascx") mycontrol.id = "statform13" mycontrol.temphospnum = "er113" mycontrol.erbednumber = "bed13" form1.controls.add(mycontrol) mycontrol.visible = true end sub
use variable references class name of user control, , use page.loadcontrol.
you can interact properties add user control class definition.
dim mycontrol yourusercontrolclassname = page.loadcontrol("~/yourlayoutfilepath/yourusercontrolfile.ascx") mycontrol.id="stratformx" me.controls.add(mycontrol)