User control with asp control : Basics « User Control and Master Page « ASP.Net






User control with asp control


<%@ Page %>
<%@ Register TagPrefix="user" TagName="SampleControl" Src="control.ascx" %>
<user:SampleControl runat="server" />


C# version (control.ascx)

<%@ Control Language="C#" %>
<script runat="server" language="C#">
void Page_Load(Object sender, EventArgs e)
{
    lblSample.Text = "Sample Control Text";
}
</script>

<asp:label runat="server" id="lblSample" />

VB version (control.ascx)

<%@ Control Language="VB" %>

<script runat="server" language="VB">
Sub Page_Load(sender as object, e as EventArgs)
    lblSample.Text = "Sample Control Text"
End Sub
</script>

<asp:label runat="server" id="lblSample" />

 








Related examples in the same category

1.Implementing a User Control on an ASP.NET Page (VB.net)
2.User control with no user interface (VB.net)
3.LoadControl user control