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 / ASP.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

Remembering textbox values on postback

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Louisa99 - 11 Mar 2008 01:47 GMT
Hello. ive just read some posts on the age old issue of losing dynamic
control values on postback. Most people say recreate the controls on the
onInit, but i just dont think this serves my purpose. if i could explain: i
have a list of reports in a datalist. a user clicks a report link. it goes
off to reporting services, fetches the parameters for this report and
displays x number of textboxes (and labels) for those parameters (hence it
must be dynamic). i do this by adding controls to a placeholder. (they are
user controls containing labels and textboxes, validation controls etc, to
control the look and feel but for simplicity we can just say textboxes). the
user enters report parameters. hits 'run report' and i need to take those
parameters and send them to the report render method. when i am about to get
the parameters, i have to go back to those controls to get the values. but
BANG placeholder.Controls.Count = 0 . Yes my controls have all gone :o(  its
not that i particularly want them to stay displayed  : i can probably manage
to convince the client that a refreshed screen will do (after all they have
their report flashed up in another window). but losing the text box value to
send to the parameter, and appropriate parameter name (i get that from the
label), that basically means i dont know what parameters the user wants to
send to the report. can anyone think of a way round this? Can I use
viewstate? or another 'alternative' someone knows about?  my code is within
an ajax update panel too if that makes a difference. (i thought this wouldnt
happen when i was writing it as i thought its an ajax call back not a
postback. but alas i was wrong. sorry for long post and thanks in advance.
louise.
bruce barker - 11 Mar 2008 02:40 GMT
update panels are a postback. the control values are sent to the server,
the page processed, then just the update panels html is sent back.

when you render the page, store the reportid in viewstate. in oninit
(and a postback), get the value and call the reporting service to get
the parameters.

your other option is to store the list of parameters in viestate

-- bruce (sqlwork.com)

> Hello. ive just read some posts on the age old issue of losing dynamic
> control values on postback. Most people say recreate the controls on the
[quoted text clipped - 20 lines]
> postback. but alas i was wrong. sorry for long post and thanks in advance.
> louise.
Louisa99 - 11 Mar 2008 10:39 GMT
> update panels are a postback. the control values are sent to the server,
> the page processed, then just the update panels html is sent back.
>
> when you render the page, store the reportid in viewstate. in oninit
> (and a postback), get the value and call the reporting service to get
> the parameters.

I will still lose the values that the user gave them parameters in teh text
box though. I have to store a key/value pair somehow then
(parametername/value). i'll read up how to do that in viewstate. thanks.

> your other option is to store the list of parameters in viestate
>
[quoted text clipped - 24 lines]
> > postback. but alas i was wrong. sorry for long post and thanks in advance.
> > louise.

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.