How to Pass parameters to Method using BreadCrumbs

Mar 28, 2011 at 1:14 PM
Edited Mar 28, 2011 at 1:28 PM

Hi,

I'm using ASP.NET MVC 2.0 and MVCSitemap2.0

My BreadCrumb is displaying like in a page

DashBoard>>HotelPolicy>>ChildPolicy View"

Here HotelPricing has a method "Create" and accepts parameter HotelCode , the problem here is i unable to pass hotelcode for Hotelpricing Create method.when i click on HotelPolicy Link that should Navigate to http;//localhost:2287/Policy/HotelPolicy/Create/HTL9834.But when i click on HotelPolicy is redirecting to http;//localhost:2287/Policy/HotelPolicy/Create/. Here I should pass the parameters to Create method of HotelPolicy

MY complete APP structure is:

web.config:

  <siteMap defaultProvider="MvcSitemapProvider">
      <providers>
        <add name="MvcSitemapProvider"
             type="MvcSiteMap.Core.MvcSiteMapProvider"
             siteMapFile="~/Web.Sitemap"  />
      </providers>
    </siteMap>

 

web.sitemap:

 <mvcSiteMapNode title="$resources:SiteMapResource,DashboardTitle"
                  url="/Profiles/Common/Dashboard"
                  visibility="InSiteMapPathOnly" changeFrequency="Always">

<mvcSiteMapNode title="$resources:SiteMapResource,HotelPolicyTitle"
                      url="/Pricing/HotelPolicy/Create/"
                      controller="HotelPolicy"
                      action="Create"
                      isDynamic="true"
                      dynamicParameters="Id">

<mvcSiteMapNode title="$resources:SiteMapResource,ChildPolicyCreateTitle"
                      url="/Pricing/ChildPolicy/Create/"
                      controller="ChildPolicy"
                      action="Create">

</mvcSiteMapNode>

</mvcSiteMapNode>

</mvcSiteMapNode>

 

Note: I did only Above thing in my application and i didnot touch controller

 

Mar 28, 2011 at 7:09 PM

In your HotelPolicy Controller, your Create Method needs a "HotelID" parameter.  That should at least get you the data.
How are you getting the ID in the first place?  I noticed ID as a dynamicparameter.  A bit more detail would be helpful. 

Mar 29, 2011 at 5:24 AM
Edited Mar 29, 2011 at 5:28 AM

Thanks tomcdona,

 

On dashBoard  i have some portlets which  contains predictive searches,so i can get  "Id( Ex: HotelID)" and can pass to my  create method of HotelPolicy Controller in normal wayand here i will pass only one ID  and that is dynamic .

In normal flow Breadcrumb display ing correctly..but when i click on HotelPolicy hyperlink in Breadcrumb .I unable to pass "Id " to my Create method

Is above Information Helpful?

Mar 29, 2011 at 5:01 PM

AH, ok.  I ran into a similar problem with specific drill down results for certain product categories.

Unfortunately, the only way I could actually get the breadcrumbs to do what I wanted was to create a Node for each entry.
So there exists in my code a DynamicNodeGenerator for each product in my databases, which allows all my breadcrumbs to display properly.

I haven't been able to figure out a better option myself, but maybe someone else here does.  I don't like the solution at all, but deadlines are deadlines......

Mar 30, 2011 at 5:29 AM
Edited Mar 30, 2011 at 5:30 AM

 

can i know How to generate node for each entry? and  also can give a  solution for how to generate dynamicnodegenetator to display breadcrumbs properly.so i can tryout in this way to resolve my problem.

or Is there any alternative way to resolve my solution.

Mar 30, 2011 at 12:27 PM

This is the best place to get started.

http://mvcsitemap.codeplex.com/wikipage?title=Dynamic%20sitemaps&referringTitle=Home

There's also a good demo in the project that comes with MvcSiteMap download.

Sep 13, 2011 at 7:26 AM
Edited Sep 13, 2011 at 7:27 AM

Can I have exact solution for my above specified Issue?