473,401 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

Extend a Class

Hello,

I have the following code:

public static class HtmlHelperExtensions {

public static string ToolTip(this HtmlHelper helper, string name)
{
return ToolTip(helper, name, null, null);
}
...

HtmlHelper is a class in System.Web.MVC.

Instead of having the ToolTip inside a new class named
HtmlHelperExtenstions can I make my ToolTip method to some how extend
the HtmlHelper, i.e., to be also inside "HtmlHelper'?

And if yes, should I do this?

Thanks,
Miguel
Sep 9 '08 #1
1 1792
If you don't control HtmlHelper, then no. However, if you ensure that
HtmlHelperExtensions is in the sample namespace as HtmlHelper, then
the extension method will be available (assuming you have a "using"
for that namespace).

Marc
Sep 9 '08 #2

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

Similar topics

0
by: ggg | last post by:
There are over 10 different XML reports I can download from someone else's server. I've made a class to parse the XML into an array. So basically I just have the start_tag() track what the...
10
by: Jerzy Karczmarczuk | last post by:
Gurus, before I am tempted to signal this as a bug, perhaps you might convince me that it should be so. If I type l=range(4) l.extend() l gives , what else... On the other hand, try
2
by: Boobie | last post by:
I switched to using this function to create element: ---------------------------------------------------- function elem(name, attrs, style, text) { var e = document.createElement(name); if...
3
by: James | last post by:
Hi, I have two classes, a base clase ItemType and a class which inherits from it called Item. During the runtime of my program, I create an instance of ItemType, then later, I would like to...
2
by: centrino | last post by:
hi, I want to extend System.Net.Sockets.ProtocolType to IPinIP protocol, how can i do that. Do i have to make new class or enum stuct for this type ? regards
2
by: Steve - DND | last post by:
Is there any way to extend the stock HtmlControls? What I'm looking to do is to still be able to plunk down <select id="blah" name="blah" runat="server"/> but have it use my CustomHtmlSelect class...
3
by: Kevin | last post by:
Hello, I do not have experience extending a vb.net class and would like some assistance. I want to extend the Microsoft.Solutions.Framework.Address class to include a phone number. How do i do...
3
by: jacobstr | last post by:
I've noticed Object.extend used in a few different ways and I'm having trouble distinguishing why certain usages apply to a given situation. On line 804 Ajax.Base is defined as follows: ...
1
by: Jeremy S. | last post by:
I'm implementing logging via the TraceSource class and related TraceSwitch and TraceListeners classes. The TextWriterTraceListener does much of what I need. But it does not roll the log over at...
7
by: cbmeeks | last post by:
Hope I'm using the right terminology. Anyway, say I have a class like: class Animal { public double GetValues() {......} public void FilterBy(string text); {......}
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.