Platform: .Net v2.0 Asp.net
Scenario: Three dropdownlist controls on a user control. In consecutive
order they are Countries, Regions, Cities. Countries is loaded during OnInit
and the other two are left disabled. Once the user selects a country, the
regions list is populated. Once a region is selected the cities list is
loaded.
Problem: When it comes to the page life cycle, there doesn't seem to be an
appropriate place to put the code to load the second and third list. To load
the list of regions you need the selected value of the countries
dropdownlist. You will only have this information during and after OnLoad.
It will work to load the list of Regions at this point, but viewstate and
postback data will no longer work, because it has already been processed by
the time the list is attempting to load.
Question: What is the best way to achieve this kind of cascading
dropdownlist whilst keeping the page life cycle happy?
Thanks
bruce barker - 06 Dec 2007 16:48 GMT
in oninit you should load the dropdowns based on viewstate or session if
not using viewstate. in onload or onchange you reload based on postback
values.
-- bruce (sqlwork.com)
> Platform: .Net v2.0 Asp.net
>
[quoted text clipped - 16 lines]
>
> Thanks
Jacques - 07 Dec 2007 06:25 GMT
We're not using viewstate so that's not an option.
Could you explain your session method in a bit more detail?
Cheers
Jacques
Adam Mather - 13 Jun 2008 15:51 GMT
What was your solution to this problem in the end Jacque?.
I am attempting to re-write an ASP / VB Script application in C# to be made available as a series of web parts to be deployed on WSS 3.0.
I have a form which has three dropdownlists. similar to your senario i require the first dropdownlist to populate the second and the second dropdownlist to populate the third.
i have tackled this problem in many different ways and am still failing miserably in my quest.
time is of the essence here - please can you guide me in the right direction?
xzzy - 13 Jun 2008 16:18 GMT
this may help you:
http://www.MyReader.net/rbr/ajax_AsynchronousLoadingOfPageInfo.zip
it's in vb.net, you can solve the problem with csharp code not properly
handling quotes by running the page webform2.aspx similar to:
<%@ Page Language="vb" %>
<script language="VB" runat="server">
Public Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
......
and let vb.net do it's thing with quotes.
I currently have a permission problem ( the new 'permission denied' post in
this ng ) when running the code on the host ( everything works just fine
running the web app locally )
to see what I am talking about,
- go to www.MyReader.net
- select Create Account
- when changing the country, the contents of the State dropdown should
repopulate but does not because persmission is denied
John Bickmore
www.MyReader.net
> What was your solution to this problem in the end Jacque?.
>
[quoted text clipped - 10 lines]
> time is of the essence here - please can you guide me in the right
> direction?
xzzy - 13 Jun 2008 17:43 GMT
I forgot to mention that
http://www.MyReader.net/rbr/ajax_AsynchronousLoadingOfPageInfo.zip
is an example of triple cascading dropdownlists
> this may help you:
>
[quoted text clipped - 38 lines]
>> time is of the essence here - please can you guide me in the right
>> direction?