Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a form in usercontrol and add this control on runtime when user click "add more option".

There is product section where user enter product details but when they need to enter more product features then need to click on "add more option", after clicking on add more option usercontrol form is added to the page. But after entering data when I try fetch the vale from the control getting null error. I could get ascx user control controls value in my aspx code behind.

If any have any idea please reply.

Thanks
Rajesh
Posted
Comments
sjelen 18-Sep-12 7:32am    
Can you show some relevant code showing you usercontrol, how do you add it to the page and how do you try to read from it?

1 solution

Not enough detail, but I think you're adding user control at runtime, not declarative in as?x.
In that case on post-back you need to make an instance of your control again and add it to the page before you can read from it. Best place to do this would be in OnInit or Page_Load.
 
Share this answer
 
Comments
coolduderaj 18-Sep-12 8:36am    
through code behind I have added usercontrol in page_load()
sjelen 18-Sep-12 10:42am    
Try to add it page OnInit override. That's earlier in page life-cycle so runtime will have a chance to parse values from request for you.
The other option is to read values by id directly from Request.Form[].
Without exact code I can't help you more.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900