I was wondering if I could add a user control to a page with a parameter and then access that parameter in the code behiind for initiallization.
For example on my aspx page i would have somethign like.
<%@ Register TagPrefix="uc1" TagName="myMap" Src="~/Map.ascx" %>
blah
blah
blah
<uc1:myMap ID="myMap1" runat="server" DefaultCountry="UnitedStates"/>
How would I access the DefaultCountry parameter in my Map.ascx.cs code behind file.
If I am off base on this what is the correct implementation?
EDIT:
Figured it out
in .aspx page
<uc1:myPartnerMap ID="MyPartnerMap1" runat="server" defaultCountry="USA"/>
in .ascx.cs of the user control
private string defaultCountry;
public String DefaultCountry
{
get { return defaultCountry; }
set { defaultCountry = value; }
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
CountrySelector.SelectedValue = defaultCountry;
}
}