Click here to Skip to main content
15,893,668 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi to all,

I have one Master Page and many number of Content page.

With in that Content pages I have the DropDownList box.

I have to access the DropDownList Control inside of the MasterPage like this

protected void Page_Load(object sender, EventArgs e)
 {

ContentPlaceHolder ct = (ContentPlaceHolder)Master.FindControl(sender.ToString());
        ControlCollection CCl = ct.Controls;
        
        foreach (Control ctrl in CCl)
        {
            if (this.Controls.GetType() == typeof(DropDownList))
            {
                strDropDownID = ((DropDownList)ctrl).ID;
                if ((strDropDownID.Contains("ddlCountry")) || (strDropDownID.Contains("ddlFromCountry")) || (strDropDownID.Contains("ddlToCountry")) || (strDropDownID.Contains("ddlOrginCountry")) || (strDropDownID.Contains("ddlDestinationCountry")))
                {
                    ClientScriptManager cs = Page.ClientScript;

                    // Check to see if the client script is already registered.

                    if (!cs.IsClientScriptBlockRegistered(this.GetType(), "DropDownListScript"))
                    {

                        StringBuilder cstext2 = new StringBuilder();

                        cstext2.Append("<script type='text/javascript'> function SelectCountry('" + strDropDownID + "') {");

                        cstext2.Append("script>");

                        cs.RegisterClientScriptBlock(this.GetType(), "DropDownListScript", cstext2.ToString(), false);

                    }
                }
            }

        }
}



The first line of the code gets Content page name but it gives an Error.

I dont know how to get the Page name of the Current Page which one is calling the Master Page.

If you know the solution to access the page name inside the master page
it would help me very much.

Thanks to all.
Posted
Updated 1-Sep-10 21:32pm
v4
Comments
Dalek Dave 2-Sep-10 3:33am    
Edited for Grammar, Syntax, Code Block and Readability.

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900