I have a master page with a treeview and I want to pass the onlick node value to a select statement that exists in the content page(in an sqldatasource control).
How can I do that?

Hi there

Try something like this

Dim MyTxt As TextBox
        MyTxt = CType(Page.Master.FindControl("ContentPlaceHolder1").FindControl("TextBox2"), TextBox)
        CType(Page.Master.FindControl("ContentPlaceHolder1").FindControl("TextBox1"), TextBox).Text = MyTxt.Text
        CType(Page.Master.FindControl("ScriptManager1"), ScriptManager).SetFocus(MyTxt.ClientID)
        ' ''Me.ScriptManager1.SetFocus(MyTxt.ClientID)

hope this helps you

A simpler way to do that would be to create a public method in the page and pass the data as a parameter.

In the master page:

void someClickEvent()
{
      if (Page is pgUserInformation)
      {
        ((pgUserInformation)Page).PassParameter("abc");
      }
}

Replace pgUserInformation with the name of the class from the code behind. This is an example of a page called "securitycode.aspx"

public partial class securitycode : System.Web.UI.Page

A more simple and safe way is to create a public static object in the master page cs and just before you open the window update its value, after that in the window you call A property to read the object.

somthing like this:

master page .cs

private static string theObjectName;

public static string TheObjectPropertyName
{
      get { return this.theObjectName; }
}

void methodOpenWindow()
{
     this.theObjectName = "somthing";
     //open the window
}

new page .cs

protected void Page_Load(object sender, EventArgs e)
{
    MasterPageName.TheObjectPropertyName;
    //and do what ever you want with it.
}

enjoy

This article has been dead for over six months. Start a new discussion instead.