Web User Control:
<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="NewUserControl.ascx.vb" Inherits="MyProjectsWebApplication.NewUserControl" %> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
Create Property for 'Web User Control':
Public Class NewUserControl Inherits System.Web.UI.UserControl Public Property Caption() As String Get Return Me.Label1.Text End Get Set(ByVal value As String) Me.Label1.Text = value End Set End Property Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load End Sub End Class
Rehister 'Web User Control' at Web-Form:
<%@ Register TagPrefix="UC" TagName="NewUserControl" Src="~/NewUserControl.ascx" %>
Using 'Web User Cotrol' in 'Web-Form':
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <UC:NewUserControl runat="server" Caption="My First Web User Control" /> </asp:Content>
Top comments (1)
thanks !!!!