I am trying to create a method that accepts multiple types of controls - in this case Labels and Panels. The conversion does not work because IConvertible doesn't convert these Types. Any help would be so appreciated. Thanks in advance
public void LocationsLink<C>(C control)
{
if (control != null)
{
WebControl ctl = (WebControl)Convert.ChangeType(control, typeof(WebControl));
Literal txt = new Literal();
HyperLink lnk = new HyperLink();
txt.Text = "If you prefer a map to the nearest facility please ";
lnk.Text = "click here";
lnk.NavigateUrl = "/content/Locations.aspx";
ctl.Controls.Add(txt);
ctl.Controls.Add(lnk);
}
}