Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

164
Vistas
Render a razor component in a new browser tab and pass a list of objects to it

I'm trying to create a control that opens a razor component and displays the objects sent to the page after a user clicks a Print button. Using the IJSRuntime.InvokeAsync() the blank page opens to a blank component page but the objects are not being captured.
Here is the button onclick event-

    public async Task PrintViewableOrderPackingSlips()
    {
        OrdersToPrint = OrdersToPack.Where(o => o.IsOrderVisible).ToList();        

        await IJS.InvokeAsync<object[]>("open", "/PrintPackingSlip", "_blank", new object[]{ OrdersToPrint });   


    }

That invokes this razor component page

@layout Blazing_Fruit.Pages.BlankLayout

@page "/PrintPackingSlip"


<body onload="window.print()">

    <Div>print page</Div>  
          

</body>


@code{


    [Parameter]
    public JsonContent orders { get; set; }

    [Parameter]
    public List<UnshippedOrder> value { get; set; }

    
}

Obviously I'm not capturing the object passed over because I get this error in the originating page

Uncaught (in promise) TypeError: cyclic object value

and this error in the new component window

Uncaught (in promise) Error: Found malformed component comment at Blazor:{"sequence":0,"type":"server","prerenderId":"aa8c4268d131416eb85784e2fcf8549f","descriptor":

How can I pass my list of objects to the new component?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Ended up using the library Blazored.LocalStorage to store the data and IJSRuntime to open a new blank window in another tab then on my blank page get the data.

@inject ILocalStorageService localStorage;

public async Task PrintViewableOrderPackingSlips()
{
    await localStorage.SetItemAsync("orderList", ordersToPrint);

    await IJS.InvokeVoidAsync("window.open", new[] {"/PrintPackingSlip", "_blank"}); 


}

Then in the page I want the data..

protected override async Task OnAfterRenderAsync(bool firstRender)
{


    if (firstRender)
    {
        var stringResults = await localStorage.GetItemAsync<string>("orderList");


        ordersToPrint = JsonSerializer.Deserialize<List<UnshippedOrder>>(stringResults).ToList();

        StateHasChanged();

        await localStorage.RemoveItemAsync("orderList");
    }
        
}

Now the only problem with local storage is it's limited to 5mb and depending on the size of my List that I am sending it will not render. So I'm guessing IndexedDb is the option for me instead.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda