Blazor Menù

Posted 201 days ago by arcturus
0

I would like, from the menu, to open a page by passing it the number of the report it has to manage

but Link="/rapportiselezione/{1}" doesn't work

Link="/rapportiselezione/"> OK

 

 <SideBarMenu>

    <SideBarTreeView Icon="fas fa-user">

    <Title>Menù</Title>

         <Items>

             <SideBarTreeView Icon="fas fa-copy">

                 <Title>Rapporti</Title>

                       <Items>

                           <SideBarTreeView Icon="fas fa-copy">

                               <Title>Magazzino</Title>

                                    <Items>

                                        <SideBarMenuItem Icon="far fa-circle" Link="/rapportiselezione/{1}">

                                            Movimenti per Articolo

                                         </SideBarMenuItem>

                                            <SideBarMenuItem Icon="far fa-circle" Link="/rapportiselezione/">

                                            Seleziona Movimenti

                                         </SideBarMenuItem>

                                             <SideBarMenuItem Icon="far fa-circle" Link="/rapportiselezione/">

                                              Totalizza Movimenti

                                         </SideBarMenuItem>

                                    </Items>

                             </SideBarTreeView>

                        </Items>

         </SideBarTreeView>

 

  • 0

    It looks like you may be attempting to use string interpolation (https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/interpolated), but you don't have the formatting quite right. There are a few ways you can go about solving this, but the following is the closest to what you're doing.

    I'm not sure what all your SideBarMenuItem component does, but I'm guessing this is what you're looking for:

    ...
    <SideBarMenu Icon="far fa-circle" Link="@($"/rapportiselezione/{id}">
    ...

    Then you'd need to assign a value to the id property in your code block. Just for example sake, I'll simply set it manually, but you'll be setting it in a method somewhere.

    @code {
        int id = 1;
        // Then the rest of your code, methods, etc.
        ...
    }

    Of course, the rapportiselezione page will need to have a page directive at top for your route that's like:

    @page "/rapportiselezione/{Id:int}"

    and in your code block of that page you'll need a public parameter to get the Id.

    @code {
        [Parameter] public int Id { get; set; }
        ...
    }
    Posted 200 days ago by selliott Edited 200 days ago
  • 0

    problem solved

    the correct string was simply

    Link = "/ selection report / 1">

    thanks anyway

     

    Posted 197 days ago by arcturus
Someone is typing...

Post a Reply

You must be logged in to add a new post.
Number of online users: 1
An error has occurred. This application may no longer respond until reloaded. Reload 🗙