Last post Jul 11, 2008 02:32 PM by jkirkerx
Jul 10, 2008 01:19 AM|bugposter|LINK
I have a masterpage , an .aspx page and many usercontrols.
In .aspx page I have taken a placeholder where I am loading user controls. My problem is that the first user control is loading fine. I am also having a button in that user control and on click of that button I want to load other user control dynamically
through code behind in the placeholder.
But what I am finding is its not firing the button event at all. The control goes to masterpage then .aspx page but never comes to this user controls button click event.
sample of my Codes are :
// this button is in the user control. On click of this it should load other user control in placeholder which is in .aspx. But problem is this event never fires.
What must be the problem here ?? Any Idea ?
your help will be highly appreciated.
Please let me know your views .
Jul 11, 2008 01:27 AM|bugposter|LINK
I found that problem is only when I add the user control dynamically. If I hard code the usercontrol into the page then the event fires...
Really eating my head...
Jul 11, 2008 07:04 AM|Peter Bucher|LINK
Aviod (!Page.IsPostBack)" and load your control on every page request. Then it works.
Jul 11, 2008 02:32 PM|jkirkerx|LINK
You have to add a handler somewhere
If you make a control dynamically, you have to a add a handler dynamically (VB Example)
txtTextBox = New TextBox
addHandler txtTextBox.Click, AddressOf txtTextbox_Click
Protected Sub btnSaveNext_Click(object sender, EventArgs e)
On a webform with code behind page
Protected Sub btnSaveNext_Click(object sender, EventArgs e) handles btnSaveNext_Click