.NETGURU
Custom Control
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngcontrolsvb' list.


Srini
Hi,
I have created a .vb file which contains the following text. How do i create my Custom Control.

Imports System
Imports System.Web
Imports System.Web.UI

Namespace MyCustomControls
Public Class CustomControl1 : Inherits Control
Protected Overrides Sub Render(Output as HtmlTextWriter)
Output.Write("This is my Custom Control ! The Time is now " & DateTime.Now.ToString)
End Sub
End Class
End Namespace

Regards
Srini
Reply to this message...
 
    
Alex Lowe
Srini,

Two things:

1) Compile your control into a assembly (more on assemblies and other
things at
(http://www.aspalliance.com/remas/ASP.NET/VFAQNET/ImportVsAssembly/).
Compiling a control in Visual Studio .NET is as simple as hitting
Build->Build 'Class Name' on the toolbar. If are not using Visual Studio
.NET then you will need to use the command line comiler for VB.NET
(vbc.exe is the filename of the VB.NET compiler). To compile your
control we would use a command line like this....

vbc /t:library /r:System.dll,System.Web.dll YourFileName.vb

The first switch (/t:library) tells the compiler that we want the output
of our compiled .vb file be of the library type. There are other types
so if you are curious then go to the command line and type vbc and hit
enter. The second switch (/r:System.dll,System.Web.dll) references the
necessary assemblies so we have access to the necessary classes.

Now, to use your control in an ASP.NET page, you will need to use the
Register directive. It would look something like this....

<%@ Register TagPrefix="myControls" Namespace="myControls"
Assembly="YourFileName" %>

and in the page you could use something like....

<myControls:YourFileName id="CustomControl1" runat="Server" />

hth,

Alex - AspFriends.com Moderation Team
Microsoft MVP - ASP.NET

***********************************************************
Have a question about using client side coding in your ASP.NET pages?
Send your question to [aspngclient]
(http://www.aspfriends.com/aspfriends/aspngclient.asp)
***********************************************************

-----Original Message-----
From: Srini [mailto:Click here to reveal e-mail address]
Sent: Monday, January 28, 2002 10:48 AM
To: aspngcontrolsvb
Subject: [aspngcontrolsvb] Custom Control

Hi,
I have created a .vb file which contains the following text. How do i
create my Custom Control.

Imports System
Imports System.Web
Imports System.Web.UI

Namespace MyCustomControls
Public Class CustomControl1 : Inherits Control
Protected Overrides Sub Render(Output as HtmlTextWriter)
Output.Write("This is my Custom Control ! The Time is now " &
DateTime.Now.ToString)
End Sub
End Class
End Namespace

Regards
Srini
| [aspngcontrolsvb] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngcontrolsvb.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives

Reply to this message...
 
 
System.DateTime
System.Web.UI.HtmlTextWriter




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification