Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / May 2004

Tip: Looking for answers? Try searching our database.

Event Handling Problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Doug Holland - 07 May 2004 23:51 GMT
Hi Ther

I have an ASP.NET user control which contains a test panel defined as follows

<asp:Panel ID="TestPanel" Runat="server" /

In the OnInit method I designate an event handler to handle the user controls PreRender event and in the PreRender event handler I create a button as follows

Button _Button = new Button()
_Button.ID = "PRButton"
_Button.Text = "Pre-Render Test"
_Button.Click +=new EventHandler(_Button_Click)
TestPanel.Controls.Add(_Button)

If I add similar code into the Page_Load, the button event successfully fires and is captured by the _Button_Click event handler

However if I click on the button added within the PreRender event handler the debugger steps into the Page_Load and PreRender event handlers but ignors the Button Click event handler

Can any one tell me why this is and also how I can potentially solve this problem

Simply moving the code into the Page_Load is not an option, I have other code that must remain within the Pre_Render event handler

Thank
Natty Gur - 10 May 2004 07:47 GMT
Hi,

You must add event handlers to dynamic create controls before the page
finished to create all controls. the last event in the page life cycle
that you can do it is Load.  

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.