473,657 Members | 2,474 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

inherits HtmlControl

my asp.net page need to display links (<a></a>) as tabs.

I create a class that inherits from HtmlAnchor as:
Public Class Tab
Inherits System.Web.UI.H tmlControls.Htm lAnchor
'(inheriting from HtmlControl is good or bad ????)

Private _Id As String = "myId"
Private _innerHtml As String = "sometext"
Private _href As String = "page.aspx"
Private _target As String = "mytarget"

Public Sub New()
End Sub

Public Overrides Property Id() As String
Get
Return _Id
End Get
Set(ByVal value As String)
_id=value
End Set
End Property

public property ... .. ... ....
'the same as above for the rest of methods
...... .. . . .. . ..
..... .. ..
...
End Class

I want to embed the HtmAnchor control within the aspx page (myDiv is <div
id='myDiv' runat=server></div>:
in the code behind I have:
..... .. . . . ....
Dim a As New Tab
a.HRef = _tab.HREF
a.ID = _tab.Id
a.Target = _tab.Target
a.InnerHtml = _tab.InnerHTML

myDiv.Controls. Add(DirectCast( a, HtmlAnchor))
but the anchor control never rendered on the page.

obviously I'm doing something wrong, what is it?

Jun 30 '06 #1
5 1583
'(inheriting from HtmlControl is good or bad ????)

htmlcontrols are not supposed to be overridden, usually there is no need, if
you want something different just create your webcontrol.
Jul 2 '06 #2
Hi zino,

I agree with Spartaco, for such scenario, we would recommend you create a
custom ASP.NET webserver control rather than html server control because
HTML server controls is not designed for further customizing and is purely
for integrated with inline html code(with runat=server mark).

Also, for creating a custom ASP.NET webserver control, I suggest you
consider creating a composite control. Composite control is a server
control which consists of other sub server controls. Therefore, you can
add the HtmlAnchor as a child control in yoru custom composite control ,
and also add some additional features(other propety or nested controls).
This also maps to the "Aggregatio n" reuse pattern in OO(in contrast to
inheritance reuse).

In addition, as for developing custom composite control, the core is the
"CreateChildCon trols" function where we should put the most control
constructing code logic. Here is the msdn reference on creating a sample
composite control:

#Composite Server Control Sample
http://msdn.microsoft.com/library/en...ositecontrolsa
mple.asp?frame= true

Hope this helps you some.

Regards,

Steven Cheng

Microsoft MSDN Online Support Lead
=============== =============== =============== =====

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jul 3 '06 #3
Hi Zino,

How are you doing on this issue? Have you got any progress or does our
suggestion help you a little? If there is still anything we can help,
please feel free to post here.

Regards,

Steven Cheng
Microsoft MSDN Online Support Lead
=============== =============== =============== =====

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jul 5 '06 #4
Hi Steven,
thank you for your feedback, I took your advise and discard the idea of
inheriting from an HtmlControl, and I'm working on the composite control.

"Steven Cheng[MSFT]" wrote:
Hi Zino,

How are you doing on this issue? Have you got any progress or does our
suggestion help you a little? If there is still anything we can help,
please feel free to post here.

Regards,

Steven Cheng
Microsoft MSDN Online Support Lead
=============== =============== =============== =====

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jul 5 '06 #5
Thanks for the followup Zino,

Glad that the suggestion has helped you some. If you meet any further
problem or need any other help on this, please feel free to post here.

Regards,

Steven Cheng
Microsoft MSDN Online Support Lead
=============== =============== =============== =====

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jul 6 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
6697
by: shine | last post by:
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="shine.WebForm1" %> what does Inherits means in this tag, what is the use of it plz explain me regards shine
4
7176
by: Ben R. | last post by:
Between ClassName and Inherits, which attribute is set to specify the class that a page uses? I would think that would be inherits. Further, the description for ClassName is: Specifies the class name for the page that will be dynamically compiled automatically when the page is requested. This value can be any valid class name but should not include a namespace. So this is what will decidw what gets compiled? Then what is the point of...
0
1382
by: Hutch | last post by:
I am looking for some thoughts on this. I have successfully gotten the HTMLControl to work using C#, and it is displaying HTML and receiving messages nicely. Unfortunately, I am not able to receive notifications from the HTMLControl. In an attempt to support this, I added a private MessageWindow derived class to the control, instantiating it in the constructor (of the control).
5
4837
by: Tim Mulholland | last post by:
If i have an HtmlControl for a table row such as: <tr id="trMyRow" runat="server">...</tr> is there any way to set this to be invisible by default through the HTML code, without having to go through the codebehind? <tr id="trMyRow" runat="server" visible="false">...</tr> does not work. its kind of a pain to have to put a whole bunch of lines like
1
1724
by: Roberto Bindini | last post by:
Hi with visual studio 2005 beta 2 i have created two form: frm1 (Inherits System.Web.UI.Page) frm2 (Inherits frm1) but in the line code : Inherits frm1 vs send error: type frm1 is not defined
4
2838
by: michael.schwarz | last post by:
Hello, is it possible to get a HtmlControl from a string including the HTML code in .NET 2.0? I was using the TemplateControl.ParseControl method in .NET 1.1, but this is not working in the new version. CIAO Michael
10
2142
by: Tony Abate | last post by:
I am working on an ASP.NET app that is going well except for one thing. I build my application and then move the .aspx file to a different directory. I can point the Codebehind property back to the .aspx.vb file in the original directory, but cannot do so with the Inherits property. I know one solution is to place the DLL file in the new directory with my .aspx file, but I would like to avoid this as it would require me to update all the...
2
1368
by: Don | last post by:
1. Say I have three classes: A, B and C. 2. Class A can only be inherited, and B inherits it. C does not inherit anything. 3. I have a function that can have an object passed to it. Either B or C can be passed to it. 4. In this function, I need to determine whether the object passed to it inherits A or not.
1
2580
by: CharlesA | last post by:
Hi folks I want to add a <ul> list with some <li> items in .net code behind on the fly I was under the impression that you could instantiate any HTML control by using the HTMLControl class with constructor parameters like so HTMLControl("ul") the purpose being that I could then program some of the attributes of the ul
0
8413
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8324
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8513
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8617
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7352
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2742
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.