views:

196

answers:

1

Hi,

I am using master page and child pages in asp.net application. I am having a drop down list and treeview( which uses sitemapdatasource) on master page. When I click on any of the treeview node,page is redirected to child page. The problem is if select any value in the drop dwn list and click on treeview node, the selected value should be assigned to at ext box in child page. This is not working.. master page_load () is executing after child page_load(), is it because of this?

Help me out in this.

Thanks Rupa

+1  A: 

Since you can't directly view a master page I'm assuming you have two pages which use a common master page. I am also assuming that this master page displays a drop down list and a treeview sitemap.

Based on this I would think that what is mostly happening is that your treeview is rendering plain old html links (i.e. <a href='http://stackoverflow.com'&gt;...). When these are clicked your browser executes a get request for the second child page. By default no data from the first child page is passed to the second.

There are various ways to change this behavior. First you should set the AutoPostBack property to true and the handle SelectedIndexChanged event on your dropdownlist. In that event you can save the value of the dropdown so that it can be restored later.

The easiest way to save this value is probably to put it in the session.

Session["myvar"] = dropdown.SelectedIndex;

Your master page can restore this value when the child page loads by doing something like:

if (!IsPostBack && Session["myvar"] != null) 
    dropdown.SelectedIndex = (int)Session["myvar"];

Another option would be to add the value to the querystring of each url in the treeview.

drs9222
Thank you..it helped me.
Rupa
One doubt is, Using Session variables in the application is good or not for a long time becoz session timeout property is there..so Can you explain this?
Rupa
Yes it is possible that the session could timeout in which case it would act just as it did in your question. However, if you are requiring that your users log in then you probably already have an issue when the session times out.
drs9222