DEV Community

0 seconds of 5 minutes, 49 secondsVolume 90%
Press shift question mark to access a list of keyboard shortcuts
00:00
00:00
05:49
 
vblover programmer
vblover programmer

Posted on

1

Asp .Net: Create a Simple 'Web User Control'

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>

Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Rehister 'Web User Control' at Web-Form:

<%@ Register TagPrefix="UC" TagName="NewUserControl" Src="~/NewUserControl.ascx"  %>

Enter fullscreen mode Exit fullscreen mode

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>

Enter fullscreen mode Exit fullscreen mode

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

Top comments (1)

Collapse
 
feded profile image
Federico Norberto Dutto

thanks !!!!

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay