CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

ASP.NET Web Hosting – 3 Months Free!



Zone: > NEWSGROUP > Asp.Net Forum > microsoft_downloads.css_friendly_control_adapters Tags:
Item Type: NewsGroup Date Entered: 8/22/2007 10:37:30 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 1 Views: 63 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
2 Items, 1 Pages 1 |< << Go >> >|
daves
Asp.Net User
Adding Custom Attributes to the Site Map Nodes so they can be used in the MenuControl Adapter8/22/2007 10:37:30 AM

0/0

dave_p_s
Jul 30 at 10:06 AM

 
Hi,
I'm new at this VS C# coding (having been used to C for many years) environment and so this question that I?m about to ask may be inappropriate for this forum but I?m hoping you will be able to answer the question or point me in the right direction.

All I'm trying to do is extend the CSS MenuAdapter.cs so that I can include a new Site Map Node custom attribute so in turn I can change the html generated by the MenuAdapter.cs to include a new attribute within the <a tag

i.e

Site Map Node
<siteMapNode url="~/GenericPage.aspx?goto=Products" title="Products" description="Create a Fundraising Page" mid="m1" />

mid attribute assigned to the <a id= tag
<a id=?m1? href="/CssAdaptersTutorial1/GenericPage.aspx?goto=SupportKnowledgeBase" class="AspNet-Menu-Link" title="Knowledge Base">Knowledge Base</a>

I then use the <a id= tag to help render my CSS rules with a little bit more control.

What I don?t know how to do is how to pull through or reference the new mid Site Map Node custom attribute within the CSS Friendly Control Adapters MenuAdapter.cs code?

Any snippets of code etc. would be much appreciated.

bdemarzo
Coordinator
Aug 1 at 2:12 AM
 
You may have more success getting a response by posting on the CSS adapter forums at http://forums.asp.net/1018.aspx

dave_p_s
Aug 1 at 1:59 PM
 


bdemarzo wrote:
You may have more success getting a response by posting on the CSS adapter forums at http://forums.asp.net/1018.aspx


Thanks.

Rinze
Today at 2:12 AM
Edited Today at 2:14 AM
 
I can't find a post concerning this question on forums.asp.net, so i'll post an answer here ;-).

The custom attribute isn't readily available to you on the menuitem, I think it's only available during databinding. So if it's an attribute for node selection, use it in a custom sitemap provider. If it has to be written to the output, use the MenuItemDataBound event to add it to the menuitem. In the buildItem method you use writer.WriteAttribute("id", item.PROPERTY).
Because you're dealing with menuitems you have to use an existing property (correct me if i'm wrong!)

and the databinding code:
protected override void OnInit(EventArgs e)
{
menu.MenuItemDataBound += new MenuEventHandler(BindCustomAttributes);
base.OnInit(e);
}

protected void BindCustomAttributes(object sender, MenuEventArgs e)
{
SiteMapNode sn = e.Item.DataItem as SiteMapNode;
if (!String.IsNullOrEmpty(sn["mid"]))
{
e.Item.PROPERTY= sn["mid"];
}
}

Hope this helps,
rinze

dave_p_s
Today at 10:21 PM
 
Hi Rinze, Thanks for taking a look at this for me. However I must still be missing something fundamental as I'm getting these errors when I compile

Error 3 The name 'menu' does not exist in the current context C:\Inetpub\wwwroot\CssAdaptersTutorial1\App_Code\Adapters\MenuAdapter.cs 35 17 C:\...\CssAdaptersTutorial1\
Error 4 'System.Web.UI.WebControls.MenuItem' does not contain a definition for 'PROPERTY' C:\Inetpub\wwwroot\CssAdaptersTutorial1\App_Code\Adapters\MenuAdapter.cs 44 24 C:\...\CssAdaptersTutorial1\
Error 6 'System.Web.UI.WebControls.MenuItem' does not contain a definition for 'item' C:\Inetpub\wwwroot\CssAdaptersTutorial1\App_Code\Adapters\MenuAdapter.cs 176 67 C:\...\CssAdaptersTutorial1\

I placed your code into the file
C:\Inetpub\wwwroot\CssAdaptersTutorial1\App_Code\Adapters\MenuAdapter.cs

placing the writer.WriteAttribute("id", item.PROPERTY) in the BuildItem method

This is my OnInit method in the same physical file:

protected override void OnInit(EventArgs e)
{
base.OnInit(e);
if (Extender.AdapterEnabled)
{
RegisterScripts();
menu.MenuItemDataBound += new MenuEventHandler(BindCustomAttributes);
}
}

Cheers,
Dave

Rinze
Asp.Net User
Re: Adding Custom Attributes to the Site Map Nodes so they can be used in the MenuControl Adapter8/29/2007 9:21:31 AM

0/0

Hi, I posted a reply to this on the codeplex forum. Did you get it to work?

Kinds regards,

rinze


Hope this helps !
Rinze

---------
please select 'mark as answer' if this post helped you!
2 Items, 1 Pages 1 |< << Go >> >|


Free Download:


Web:
Adding Custom Attributes to the Site Map Nodes so they can be used ... Adding Custom Attributes to the Site Map Nodes so they can be used in the MenuControl Adapter. Last post 08-29-2007 5:21 AM by Rinze. ...
Custom attribute to sitemap datasource - ASP.NET Forums NET 2.0 CSS Friendly Control Adapters 1.0, they provide the source code ..... In fact, you can add the custom attribut for the sitemap node, ...
Extending ASP.NET 2.0 Menu Control To Have Tabs With Rounded Corners This provided code for creating an Adapter for the Menu control that ... way an adapter works is pretty similar to how a custom control works; so I was able ...
CodeProject: Using Multiple Sitemap Files in ASP.NET 2.0. Free ... Jan 10, 2006 ... But what about placing your sitemap files in app_data (so that they can't be downloaded), or having multiple nav bars and wanting a sitemap ...
Download free ASP templates - Free ASP Templates. So, for example, an adapter can improve the Menu control so it renders
    tags ..... NET then you're probably used to adding style sheets to your pages ...
    Website Navigation Adding Custom Site Map Information. In the site maps you’ve seen so far, ...... adapters that can alter the rendered markup of both controls so they use ...
    Commonality - May, 2006 In it, I grab the SiteMap, clone the root, remove the children and then ... It appears the adapter can be downloaded now for free if you register at the new ...
    A Subtext Community People from the Brighton Centre itself were taking pictures so they could prove ..... this comes from the same site map file as the first SiteMapDataSource. ...
    Custom SitemapProvider with multiple sitemap files - Rinze Cats' Blog More importantly, you just can't go around adding providers for each external sitemapfile. .... I have put sitemap node entry in custom.sitemap as below. ...
    .NET ASP Page 61 - Bytes Site Map 2.0: custom attributes not rendered for textbox · need help on application variables .... Can ClickOnce Deployment be used with WebApplication ...




Search This Site:










dataview count errors out

page is getting blinking while using update panel also..any solution?

can usercontrol return value?

time question

error dialog box: no source code available for the current location

as datetime = datetime.now....

asp.net 1.1 application folder does not work if it is inside an asp.net 2.0 application folder

how can i free the memory, after i use window.close() or self.close in client-side?

findcontrol not working

my namespace?? (loading controls at runtime)

rolemanager error

problem with classes and inheritence...

is it possible to get the path using virtual directory asp.net project

do url session ids affect spidering?

object reference not set to an instance of an object.

how to get variable back from the url "index.aspx?userid=15&role=client?

opening a window

changeing back ground color based on data base information

google translation problem

global.asax & web.config - error handling

how can i make the intellisense good.

good css reference book or website?

how to populate data from dataset?

pre-select a value in the drop down list

some questino regarding sql statement.

trying to attach a seperate code behind - in addition to default.aspx.vb

viewstate

reporting tools or engines for .net

help w/ vb to c#

messagebox in asp.net

  Privacy | Contact Us
All Times Are GMT