Question

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

Was it helpful?

Solution

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'>...). 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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top