Click here to Skip to main content
15,913,854 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
i want to call master page from content page ..
means:-i have two drop down of country and city in content page..
and save button in master page..
but when select country and city from both dropdown then only save button is enable (true) else it is enable (false) means we cannot save data if not select city and country...
so how can i do????
plz help me..
thanks in advance.
Posted

Try the sample below to access master page control :

C#
DropDownList  ddlCountryList = this.Page.Master.FindControl("ddl_Country") as DropDownList;


You may also refer :
Interaction Between Content Page and Master Page[^]
 
Share this answer
 
v2
Comments
Member 9027483 2-Nov-12 3:37am    
in which i put this code???
means i tried it in content page but when i changed in that means i was try to replace my button name but it not support so plz hepl me how to implement above code??????
Kuthuparakkal 2-Nov-12 3:58am    
You need to put this in content page code behind. This way you are accessing the DropDownList(say ddl_Country) present in Master page for the content page. Once you get ddlCountryList check if it's null or not. If not null you can definitely access it's items or SelectedItem index or any property of it.

Same way you can search for textboxes or any other control.
I guess you need to access the button control of master page. You should create a Button object and then instantiate it with the master's page button control. Place the code in Content page.

C#
//This code is in Content page aspx.cs file. 
//Creating Button Object
Button masterSaveBtn = new Button();
//Below code does type Casting to Button type
masterSaveBtn = (Button)this.Page.Master.FindControl("Save");
masterSaveBtn.Enabled = false;


FindControl() method takes Control's programmatic ID as a parameter. Here in this case, I'm assuming your Save button's ID on Master page is "Save".
Hope that helps.
 
Share this answer
 
Why not use javascript?
set drop down's attribute 'onchange'...
Hope that helps!
 
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