Very important to learn the basics in atlas ajax programming. NK's blog once agian has a sexy introduction to this
Showing posts with label Ajax. Show all posts
Showing posts with label Ajax. Show all posts
Saturday, October 6, 2007
Wednesday, September 5, 2007
Dynamic CascadingDropDownExtender Control and Viewsate
Spent some time at work trying to get the cascadingdropdown extender control (that comes with AJAX tollkit ) to work according to my needs. The intention was not to do some thing very complicated , a simple page with dynamic controls ( parent-child chain of dropdowns) being added at runtime. Looking at the sample app that ships with the ajax toolkint tells at best the different usage of each controls\extenders.
- Preset a default value: One bit where I was challanged in the start was to get my drop downs populated with a default value ( like when you open a page in edit mode ) , it took me a while to figure out that setting SelectedValue property of the cacading extender control actually sets the default value and not by simply adding items to the dropdown , something that we would usually do. Another interesting thing to notice was that the default value gets set via an ajax call after the page is rendered on client side ( browser ).
- Viewstate: Another thing I did not get working in the first go was , persisting the dropdown viewstate after a post back. The client side script was working its job all fine with the parent-child data coming as response with the asynchronous ajax calls,etc. It was in the end ( when I thot all the hardship is over ) I realised that the selected value of the dropdowns wre not available after a postback ( dejavu... dynamically added controls ). Although I did make sure to give the same ID for the respective dropdowns to have the 'dynamic control viewstate' theory do the rest of the job for me , but not so lucky. After a bit of googling found out that if I add these controls in the OnInit function ( override OnInit and add the control dynamically here ) rather than page load it works perfect. .... i always have hate this solution. I ended up using the old asp way of getting the value from the form request bag. ( Request.Form[dropdownList1.UniqueID] )
Subscribe to:
Posts (Atom)