Dynamically Loading Controls in a WebPartZone
I have configured my page to use WebPart — [Added WebpartManager,WebpartZone – Left,Center,Right]. Now, i show some list of items like Cricket Score, Current Weather….user can select one of them and when he/she says “OK”..I want to add my controls in WebpartZone..
Okay, leave this much complex i have one button on Webpart page on click of it i want to add one Calendar control to Webpartzone..How can i do this??
you can do easily using following piece of code:
Calendar calendar = new Calendar(); GenericWebPart gwp = wpm.CreateWebPart(calendar); //wpm = Webpartmanager //OR to get current webpartmanger use : WebPartManager.GetCurrentWebPartManager(Page) method //Add Webpart wpm.AddWebPart(gwp,wpzb,i); //webPart,WebpartZone,ZoneIndex