Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Using callback, I fill dorpdownlist without postback but it gets empty when a postback is executed

Reply
Thread Tools

Using callback, I fill dorpdownlist without postback but it gets empty when a postback is executed

 
 
Fabio Mastria
Guest
Posts: n/a
 
      01-19-2008
Hi all!

In a my simple project I use callback to fill a dropdownlist with xml data
returned by a web service, based on a value which is input via another
dropdownlist.

NOTE: I can't use ajax/atlas.

Using javascript and callback all works... but if I press a button or any
event that raise a postback, the dropdownlist that I fill gets empty!

This also if I set its EnableViewstate property to false.

Someone can help me?

Thank you and regards
F.

 
Reply With Quote
 
 
 
 
JIGNESH
Guest
Posts: n/a
 
      01-19-2008
Is Button a HTML Submit Button or a normal HTML Button. ?

Regards
JIGNESH

"Fabio Mastria" wrote:

> Hi all!
>
> In a my simple project I use callback to fill a dropdownlist with xml data
> returned by a web service, based on a value which is input via another
> dropdownlist.
>
> NOTE: I can't use ajax/atlas.
>
> Using javascript and callback all works... but if I press a button or any
> event that raise a postback, the dropdownlist that I fill gets empty!
>
> This also if I set its EnableViewstate property to false.
>
> Someone can help me?
>
> Thank you and regards
> F.
>
>

 
Reply With Quote
 
 
 
 
Peter Bromberg [C# MVP]
Guest
Posts: n/a
 
      01-19-2008
The reason why ViewState isn't working for you is that you are populating the
dropdownlist in the browser with client script. Since there is no postback
event from this, nothing gets stored in Viewstate. So in order to handle this
you would need to repopulate your dropdown if there is a postback. The server
- side code has no knowledge of the <option ..> elements that you've put into
the control client - side.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com


"Fabio Mastria" wrote:

> Hi all!
>
> In a my simple project I use callback to fill a dropdownlist with xml data
> returned by a web service, based on a value which is input via another
> dropdownlist.
>
> NOTE: I can't use ajax/atlas.
>
> Using javascript and callback all works... but if I press a button or any
> event that raise a postback, the dropdownlist that I fill gets empty!
>
> This also if I set its EnableViewstate property to false.
>
> Someone can help me?
>
> Thank you and regards
> F.
>
>

 
Reply With Quote
 
Milosz Skalecki [MCAD]
Guest
Posts: n/a
 
      01-19-2008
Howdy,

I don't think it matters as he populates drop down list on the client side
using callback (XMLHttpRequest) AJAX, so the information is not persited in
viewstate, the only information being sent back to the server with HTML form
is selected value. He'd have to either serialize values to hidden field and
deserialize it on the aspx page and populate the drop down list, or populate
drop down after every postback on the client side. Fabio if you need more
explanation please don't hesitate to let us know.

Regards
--
Milosz


"JIGNESH" wrote:

> Is Button a HTML Submit Button or a normal HTML Button. ?
>
> Regards
> JIGNESH
>
> "Fabio Mastria" wrote:
>
> > Hi all!
> >
> > In a my simple project I use callback to fill a dropdownlist with xml data
> > returned by a web service, based on a value which is input via another
> > dropdownlist.
> >
> > NOTE: I can't use ajax/atlas.
> >
> > Using javascript and callback all works... but if I press a button or any
> > event that raise a postback, the dropdownlist that I fill gets empty!
> >
> > This also if I set its EnableViewstate property to false.
> >
> > Someone can help me?
> >
> > Thank you and regards
> > F.
> >
> >

 
Reply With Quote
 
Fabio Mastria
Guest
Posts: n/a
 
      01-22-2008
Peter Bromberg [C# MVP] wrote:
> The reason why ViewState isn't working for you is that you are
> populating the dropdownlist in the browser with client script. Since
> there is no postback event from this, nothing gets stored in
> Viewstate. So in order to handle this you would need to repopulate
> your dropdown if there is a postback. The server - side code has no
> knowledge of the <option ..> elements that you've put into the
> control client - side. -- Peter


OK Peter it is clear... but how I can recover the data used to fill the
dropdownlist in the previous roundtrip?

I someone want, I can send via mail the entire project (visual studio 2005).
I fail continuously

don't know what to do...

in the callback functions, If i fill the dropdownlist or not, it's the same,
because callback doesn't affect the viewstating process.

help :/

thank you

 
Reply With Quote
 
TechMCAD13 TechMCAD13 is offline
Junior Member
Join Date: Jan 2008
Posts: 1
 
      01-30-2008
Use a hidden textbox to store selected value of the dropdown. U need to store using client script.

When postback happens generate the dropdown in the backend and then
select the value using the hidden textbox value.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XMLHttpRequest gets data to display in element but data gets appended not replaces previous! libsfan01 Javascript 5 12-20-2006 06:25 AM
Not only the selected HREF gets surrounded, but the whole row gets surrounded Stefan Mueller HTML 5 07-10-2006 11:53 AM
ORIGINAL CODE GETS EXECUTED NOT THE NEW CODE - ASCX sk ASP .Net 1 04-19-2006 11:50 AM
a different web.config gets executed Sammy ASP .Net Web Services 1 01-28-2005 09:10 PM
Page_Unload gets executed twice chefo@bulgaria.com ASP .Net 0 01-21-2005 01:44 PM



Advertisments