User control with no user interface (VB.net)
<%@ Page Language=VB Debug=true %>
<%@ Reference Control="UserControlNoInterface.ascx" %>
<script runat=server>
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
Dim MyControl as UserControl = _
LoadControl("UserControlNoInterface.ascx")
lblMessage.Text = "PI: " & _
CType(MyControl, UserControlNoInterface).ReturnPI _
& "<BR>PI Rounded: " _
& CType(MyControl, UserControlNoInterface).RoundPI(3) _
& "<BR>Circle Circumference: " _
& CType(MyControl, UserControlNoInterface). _
CircleCircumference(2)
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>Implementing a User Control on an ASP.NET Page</TITLE>
</HEAD>
<BODY LEFTMARGIN="40">
<form
runat="server"
id="MyForm"
>
<asp:label
id="lblMessage"
runat="server"
/>
</form>
</BODY>
</HTML>
<%--UserControlNoInterface.ascx
<%@ Control className="UserControlNoInterface" %>
<script language="VB" runat="server">
Public ReadOnly Property ReturnPI() As Double
Get
ReturnPI = Math.PI
End Get
End Property
Public Function RoundPI(DecimalPlaces as Integer)
RoundPI = Math.Round(Math.PI, DecimalPlaces)
End Function
Public Function CircleCircumference(TheRadius as Double) as Double
CircleCircumference = TheRadius * TheRadius * Math.PI
End Function
</script>
--%>
Related examples in the same category