By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,617 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

Page_PreInit User Control NullReferenceException

P: 2
Hi, i am new in the forum ^^

I have an issue

I got a webpage that uses a UserControl wich create dynamic controls on him, i need to create the controls on the Page_PreInit event so i can access to them in the postback when the user do a click, but when i am at the PreInit event the UserControl is null so i cant create any control.

Can someone explain how to do this?

in my specific case my user control got 2 accordions, and 2 buttons, the idea is moving panes from one acccordion to another, so i created dynamic panes with dynamics controls like, checkbox, textbox, etc and add to the accordion, then user check the checkboxs on the panes, and by clicking pass those panes to the other accordion, the problem i got is that on postback the accordions on the userControl dont have any panes so i need to create them on Page_PreInit to maintain the state.

Thx!
Nov 23 '12 #1
Share this Question
Share on Google+
3 Replies


zmbd
Expert Mod 5K+
P: 5,371
Please post the code that you've already worked on; formating it using the <CODE/> button in the toolbar.
Nov 23 '12 #2

PsychoCoder
Expert Mod 100+
P: 465
Have you tried the Page_Init event? Possible in PreInit it;s too early in the page cycle for the control to be actually created and accessible (just a thought)
Nov 23 '12 #3

P: 2
It works fine using the Page_Init event instead od Page_PreInit, i dont know why i didnīt try that before post lol xD

thx for the answers guys!
Nov 23 '12 #4

Post your reply

Sign in to post your reply or Sign up for a free account.