User control resets the form elements

F

Furkan Atli

hi,
i have an aspx page with 3 ascx files(header,footer,left
menu).
my aspx page several textbox and dropdowns.some dropdowns
submit the form when selection change.and all other
textbox and other elements reset!
but you know asp.net don't reset the form elements when
the form submit.,
if i remove ascx pages it is working and dont reset the
form elements.but i need to use ascx files.
i dont want to reset elements when form submit.Please help
me.
 
V

Victor Garcia Aprea [MVP]

Hi Furkan,

Are you dinamically creating and adding controls to the control tree? It
looks like some of your controls are not there when postback data is
processed.

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx

To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
 
S

shoeb

I am having problem maintaining state of user control .
I am loading then dynamically.
here's the code
-----------
System.Web.UI.WebControls.PlaceHolder phAD;
AttributeDetail ucAttributeDetail;

ucAD= (AttributeDetail)LoadControl
("AttributeDetail.ascx");
phAD.Controls.Add(ucAD);
----------

during postback am not able to maintain state of my user
control
am I missing something
Please help
please cc it to (e-mail address removed)

Thanks
 
V

Victor Garcia Aprea [MVP]

Can't tell much by your posted code. At which point is it running? The
important thing is that you add the control to the control tree:

as early as possible in the page execution lifecycle (Init, Load)

If you're adding it in response to a click event or such then you're out of
luck as at that point the postback data has been already processed and your
control wasn't in the tree to receive it.


--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx

To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top