Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
1.80/5 (2 votes)
I had a Nested Master Page.First Master and Main Master and this dropdown is on First Master i need its value in page for server event for fetching data from DataBase parent.document.getElementById('MDDL_Dept').value


Thanks,
Posted
Updated 20-Oct-14 22:41pm
v5

try proving both masterpages contentplace holder ids in socument.getelemntbyid
i.e document.getElementById
('Contentplaceholderidofmainmaster_contentplaceholderidoffirstmaster_MDDL_Dept').value
 
Share this answer
 
v2
Comments
Laiju k 18-Oct-14 9:19am    
parent.document.getElementById('MDDL_Dept').value works well on client side. i need to get the control value on serverside on pageload
to get master page control we need to get the control first and then used it

C#
var dropdown=(DropDownList)Master.FindControl("MDDL_Dept");
            if (dropdown != null)
            {
                //you code
                string yourvalue = dropdown.SelectedValue;
            }
 
Share this answer
 
Comments
Laiju k 21-Oct-14 0:13am    
I want it on the Serverside like we take control from GridView using findcontrol is there a way to access the control get the value on serside.If we can get the value on pageload.I had many things i cant access it on page load after that my code is working.
VC.J 21-Oct-14 0:43am    
can you provide the code what you have written ,
I get the master page control in my page by using the same code that I have provided to you in my solution .
Pageload what you are pointing out is the pageload event I guess so you need to that code inside pageload event like
protected void Page_Load(object sender, EventArgs e)
{
var dropdown=(DropDownList)Master.FindControl("MDDL_Dept");
if (dropdown != null)
{
//you code
string yourvalue = dropdown.SelectedValue;
}
}
Laiju k 21-Oct-14 1:01am    
I have nested master page.I will try your code.Thanks for the effort.

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