Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
myusercontrol ctrl = (myusercontrol)Page.LoadControl("~/directory/to/myusercontrol.ascx");
<%@Register tagprefix="foo" src="~/directory/to/myusercontrol.ascx" tagname="bar" %>
<foo:bar runat="server" id="blah" />
public class MyUserControl : UserControl
{
...
public string Text
{
get {return textbox.Text;}
set {textbox.Text = value;}
}
}
void Load(eventArgs e)
{
instanceOfMyUserControl.Text = "foo";
}
this could lead to problems down the road. for example a new developer must know about the query string value. the querystring is related to the page, not the user control. this logic should be preformed on the page which tells the user control to load the data.The actual user control itself checks for an id in a querystring. If it is greater than 0, the user control fires a method to grab data from a database, at the data layer, return the datatable, and sets the textbox value to a cell value in the datatable.
public void load_data(int id)
{
if (id == 0) return;
a_textbox.text = new data_service().get_data_by(id).a_property;
}
public void Load(EventArgs e)
{
int id = 0;
int.TryParse(Request.Params["query string key"], out id);
my_user_control.load_data(id);
}