overrides and implementing on a page

Ok, I want to override a MenuItem's Render() method.  (Specifically, I want to eliminate the && (num < this._owner.MaximumDepth) segment in order to manually control whether an item's children get rendered.)  So, on my codebehind, I have a derived class: class AtomicMenuItem : MenuItem with the override method.  Now, my question is, how do I implement the new class on my page?

<asp:Menu ID="nav_Left" runat="server" MaximumDynamicDisplayLevels="0">
        <asp:MenuItem Text="Home" Value="Home"></asp:MenuItem>
        <asp:AtomicMenuItem Text="My Account" Value="My Account" >
            <asp:MenuItem Text="Change Password" Value="Change Password"></asp:MenuItem>
        <asp:MenuItem Text="Resources" Value="Resources"></asp:MenuItem>

4/29/2009 5:08:00 PM
asp.net.custom-server-controls 3498 articles. 0 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 26

Or, maybe I can't do this because MenuItem is a sealed class... Is there a way to extend/override methods on sealed classes?
4/29/2009 5:43:52 PM

Is there a way to extend/override methods on sealed classes?


No we cannot derive from a sealed classes. If you can clarify your requirement we can discuss on it to see if there's another way to achieve it.

Allen Chen
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
5/4/2009 6:04:54 AM

Similar Artilces:

Creating .Net custom server controls and .Net pages programatically
Thanks a lot for reading this and greatly appreciate your inputs I am writing a webinterface that lets users configure options that'll create an interface for them and generete the webpage. So I am having to programattically create custom server controls and .Net page with code behind to support the functionality. Are there APIs in the .NET SDK that let you do this. Any pointers would be greatly helpful Thanks a lot Sathya Controls on the fly? Or Create code on the fly? I think it is the latter so here we go - look at the following namespaces: * System.Reflection.Emit - gen...

Usercontrol vs Custom Server Controls, Any need for Custom Server Controls
Hello I'm new to ASP.Net so this is probably a stupid question but, is there any need to create customer server controls now that you can pre-compile usercontrols into a dll and thus easily share between applications? This blog post from David Ebb describes how to do it and the restrictions he note don't seem that bad (other than being able to embed resources such as images in the dll). http://blogs.msdn.com/davidebb/archive/2005/10/30/487160.aspx His article desribes the techniques for ASP.Net 2.0 and he suggests that there will be further improvements in .Net 3.5 in this ar...

Custom Server Control Vs Web Parts, Any need for Custom Server Control
Hello I've just posted a similar question on why you need server controls when you can pre-compile usercontrols and redistribute them. http://forums.asp.net/p/1397433/3010100.aspx#3010100 I've seen lots of (usercontrol vs web part) but not much on web part vs custom server control. According to the MSDN site you can put web parts onto a normal asp.net page outside of a web part zone and they behave just like custom server controls. So, if you are creating a bunch of controls for redistribution to customer asp.net sites and/or SharePoint sites why don't you just create Web Par...

problems listenening to events on a custom server control from another custom server control
 Hi all,I am having problems listening to events on one of custom server controls(AddBookmark) from another custom server control(BookmarkList). The listener or the BookmarkList control has a property that can be set to the AddBookmark control (string at design but the reference is obtained at run-time). I am able to get a reference to the AddBookmark control and add a listener to it on the BookmarkList control on the OnPrender of BookmarkList. But the problem is that when the events on AddBookmark gets fired, the listener added from the BookmarkList is no longer present and the listene...

Custom Server Control Made of Custom Controls?
I'm giving myself a crash course in custom server controls, and I have a quick general question. Can I have a custom server control that is composed of other server controls I created. I'm pretty sure the answer is yes, but I want to be positive. Yes http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpcondevelopingcompositecontrols.asp Shows how to combine existing controls into a new control using class composition. -ron Thanks! ASP.NET so rocks! Making page components extensible objects is such a great idea! I love it....

how to add a server control to a page from other server control
I have a control that needs to be added at a precise location on a web form using a server control i designed. I tried to add the control using this.Controls.add(controlName) but its just appending to the existing control. Is there a way to add a control to another control at a precise location?  I think adding it to a string builder is a feasible option for me, but I guess I cant do that. any suggestions as to how to implement it please? in one control you add PlaceHolder, And Create one Public property which return PlaceHolder..  then when you add the control in Web For...

How to create custom properties for aspx page which should refelect in design time properties window itself.( as like as custom server control).
Hi. I need to create the custom properties for aspx page itself where those custom properties should refelet in the properties window at the design time as like as other custom server controls. I tried pageBase class which will have cusom properties for page and inherited that pageBase to my aspx page . But its refelecting the code  behind file not in design time. I need to accss those aspx page custom properties at the design time itself in properties window as like as other custom server control.I appriciate your help. [FYI: my scenerio is customer ...

Overriding Visibility on Custom Server Control
I'm creating a custom server control, and am having trouble overriding the visibility property.  What I would like to do is to override the property and set the value to a private bool that I can then check against.  If the control is then set to false, I'd like to run a chunk of code that inserts some javascript our master page needs to compensate for the missing control while still preventing the markup from rendering.  For whatever reason it seems my private bool is being set properly in the override get/set but the control still shows respects the visible=false req...

how to have both server controls and html controls rendered in a custom control?
I have a custom control in which there is an html text box.when you click on it , a div containing a table is appeared and according to what you select in that table a text is set to the text box. It works fine but the problem is: as the text box is an html element it doesn't have viewstate and when a post back occures in the page its value disappeares.I tried a hidden field to keep its value.again there is another problem : I put this custom control in a usercontrol and put the usercontrol in a multiview and by clicking on a button this view is selected and by clicking another bu...

Custom Control: Calling a function on calling page FROM a custom control ? help !!
I have a custom control placed on many pages, to make things simple, basically what I want to do is Call a function on the calling page from the custom control ieAnyone have any ideas, simple solution would be good !!  This is the code I have myControl.ascx.vbPublic Partial Class myControl    Inherits System.Web.UI.UserControl    Protected Sub testButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles testButton.Click        'call save function on PersonalDetails.aspx.vb  &...

Overriding width property on a custom server control
I have a custom web server control that consists of three dropdowns.  I am trying to override the Width property and set it to a default width of 128 pixels.  The property is defined as follows: <Bindable(True), Category("Appearance"), DefaultValue("128px")> Overrides Property [Width]() As Unit        Get            EnsureChildControls()            Return mWidth        End Get    &n...

Custom Server Control does not exist on page load
Hello.  I've been struggeling with this for quite some time now and really need some help.I've been building custom server controls for some time and have some bits of knowledge missing that is causing me som problems.Here's the situation.  I built a custom server control that returns a control that consits of an ASP.NET Textbox, Ajaxcontrol toolkit watermark extender, and image and a bunch of other stuff.  The end result being a "Filter TextBox" that is used to apply filters on GridViews.  The problem is that when the gridview OnLoad event fires to ...

Custom server control
I am trying to create a simple generic pager control. I want to get the current page index from the querystring of the parent page that contains this pager control. I built the control and try to drop it on an aspx page, it shows an error. It's because of this line in the render method (no error if I comment this line out), where I retrieve the current page index from the page querystring. Like this: HttpContext.Current.Request.QueryString["page"] The error is 'object reference not set to an instance of an object'. There is no request object or parent page or querystring at design...

Custom Server Control launching new page
I am developing a new custom server control, my first. It is essentially a table that displays information about a server. What I want to do is to include in the control a link to open a new web page to perform a task, such as pinging the server. So you would click on an icon in the server control and a new window would popup displaying the pinging results in it. I would like to keep this "sub page" within the server control itself. I know I could just create a new web page and insert a link into my control. You could use some JavaScript trickery and open a new window using the window.sho...

Building .NET Custom Server Controls and distribution
Can anyone tell me the best practice for distributing custom controls or controls that have been developed from inheriting server controls? I am curious how other companies support a custom library of objects developed by developers within an enterprise. At my company we follow the naming standards put forth by Microsoft: CompanyName.AppName.LayerName Example: Say I developed a Drop Down List that is used to display every year from 2004 to DateTime.Now in ascending order from inheriting the Web Server Control Drop Down List.  After a committee of other developers have tested and app...

Web resources about - overrides and implementing on a page - asp.net.custom-server-controls

Implementing Recommendations of the 9/11 Commission Act of 2007 - Wikipedia, the free encyclopedia
Passed the House on January 9, 2007 (299-128 Roll call vote 015 , via Clerk.House.gov) Reported by the joint conference committee on July 25, ...

Hearing on “Reviewing the Rules and Regulations Implementing Federal Wage and Hour Standards.” - YouTube ...
SUBCOMMITTEE ON WORKFORCE PROTECTIONS hearing at 10:30 a.m. in room 2175 Rayburn House Office Building. Hearing on “Reviewing the Rules and Regulations ...

Iran, U.S., EU begin implementing historic nuclear deal
Iran unplugged banks of centrifuges involved in its most sensitive uranium enrichment work on Monday, prompting the United States and European ...

Iraq to talk with Syria on implementing AL deal
Iraq on Thursday agreed with the Arab League (AL) to try to convince Syria to implement the bloc's initiative in a bid to avoid economic sanctions ...

Iran says differences over implementing nuclear deal solved: negotiator
Montreal Gazette Iran says differences over implementing nuclear deal solved: negotiator People's Daily Online Global TimesChinadaily.com.cn ...

China, Kazakhstan to enhance cooperation by implementing Silk Road initiative
China, Kazakhstan to enhance cooperation by implementing Silk Road initiative

Guess? exec says company saw immediate improvements after implementing iPads in stores
BusinessInsider pointed us to an interview on OpenForum with CIO of clothing retailer Guess?, Michael Relich. The company implemented iPads for ...

Sheriff Joe Arpaio: MCSO implementing 'patriotic' campaign with US flag at each cell
The Maricopa County Sheriff’s Office announced it started a campaign to display U.S. flags on every cell among its jails. Any vandalism will ...

Change Has Come: OFCCP Publishes Final Rule Implementing Executive Order Prohibiting Federal Contractors ...
The U.S. Department of Labor’s Office of Federal Contract Compliance Programs (“OFCCP”) published a final rule today, implementing Executive ...

Resources last updated: 12/15/2015 8:13:34 AM