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

Discussion in 'ASP .Net' started by Fabio Mastria, Jan 19, 2008.

  1. 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.
    Fabio Mastria, Jan 19, 2008
    #1
    1. Advertising

  2. Fabio Mastria

    JIGNESH Guest

    RE: Using callback, I fill dorpdownlist without postback but it gets e

    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.
    >
    >
    JIGNESH, Jan 19, 2008
    #2
    1. Advertising

  3. RE: Using callback, I fill dorpdownlist without postback but it gets e

    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.
    >
    >
    Peter Bromberg [C# MVP], Jan 19, 2008
    #3
  4. RE: Using callback, I fill dorpdownlist without postback but it ge

    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.
    > >
    > >
    Milosz Skalecki [MCAD], Jan 19, 2008
    #4
  5. Re: Using callback, I fill dorpdownlist without postback but it gets e

    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
    Fabio Mastria, Jan 22, 2008
    #5
  6. Fabio Mastria

    TechMCAD13

    Joined:
    Jan 30, 2008
    Messages:
    1
    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.
    TechMCAD13, Jan 30, 2008
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    437
  2. sk
    Replies:
    1
    Views:
    429
    Karl Seguin [MVP]
    Apr 19, 2006
  3. Stefan Mueller
    Replies:
    5
    Views:
    507
    Steven Saunderson
    Jul 10, 2006
  4. Sammy

    a different web.config gets executed

    Sammy, Jan 27, 2005, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    99
    Sammy
    Jan 28, 2005
  5. libsfan01
    Replies:
    5
    Views:
    229
    Jeff North
    Dec 20, 2006
Loading...

Share This Page