Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

asp.net - setting viewstate of a control manually

Options
  • 11-05-2007 9:37am
    #1
    Registered Users Posts: 872 ✭✭✭


    Hi,

    Im doing up a form that uses the Anthem AJAX framework, basically they are the same web controls as normal but they work without having to do postbacks which is really handy. One problem is that when i bind a repeater the viewstate doesnt get set, so if you go to another page and then press the browser back button the repeater isnt bound anymore.

    Im wondering how can i set the viewstate of the repeater manually. I cant really find any good resources online yet (im still looking)

    Any help is great.


Comments

  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    I dunno how you would do it but my *current* understanding is that the entire page has to be executed for ViewState to be available to the controls. Asynchronous posting shouldn't execute the entire page so I assume that the Anthem framework doesn't do this..

    Now if you use the UpdatePanel with comes with the Asp.Net Ajax framework the entire page will be executed. But then you have the opposite problem. While it appears to have the same user experience, there's a lot more bandwidth and server load involved with the UpdatePanel because the page is executing which nullifies one of the advantages of Ajax imho.

    So my answer is: I don't know. But keep me upto date on your solution please :)


  • Registered Users Posts: 872 ✭✭✭grahamor


    Thanks for the reply, ill check out the update panel idea.

    I was on the Anthem forums and i saw alot of posts about adding stuff to the page cache and using sessions but im not too familiar with adding stuff to the cache. I tried using sessions but the page needs to be reloaded i think.

    When you press the back button on a browser does the page actually get reloaded (i.e. call the page_load method) or is it just cached ?

    The more i think about the potential problems with this the more im inclined to go back and use the regular web controls with postbacks :mad:


  • Registered Users Posts: 2,299 ✭✭✭PixelTrawler


    I use Anthem controls quite a lot and have never run into many problems with them although I tend to never use the back button because it can break Ajax pages.

    Havent ever received any complaints from my users either.

    As far as I know the Anthem.js does the job of keeping the viewstate up to date for the controls with each partial postback. however it is possible hitting the back button will mess it up since the back button moves the whole page back to the last step before you started partial post backs.

    I've used Anthem on four projects and never had a single user complain about use of the back button.

    It might be a problem you wont have to worry about too much


  • Registered Users Posts: 872 ✭✭✭grahamor


    So i added in the following into my web.config

    <add key="Anthem.BaseUri" value="http://localhost/blah/includes/js/&quot; />

    so the js is referenced externally (instead of all the js being put into every page by default) and suddenly the viewstate works. If i bind 2 repeaters, go to another page and press back they are still bound.


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    Where in the web.config did you put that? Was it in <appSettings>?


  • Advertisement
  • Registered Users Posts: 872 ✭✭✭grahamor


    Yeah in app settings.

    If you dont include a reference to the js at all each page you use the Anthem directive on contains all the Anthem js, which is alot and really adds alot to each page.

    This way is much cleaner and the viewstate issue i had is now fine.


Advertisement