How to pass a parameter in Component.InvokeAsync?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
1 ano atrás
Hi.
How to pass a parameter in @await Component.InvokeAsync("RelatedProducts", new { productId = Model.Id })? ViewData?
Thanks.
1 ano atrás
you need to overwrite RelatedProducts view component's code because it's input param is fixed
1 ano atrás
Rashed Khan wrote:
you need to overwrite RelatedProducts view component's code because it's input param is fixed


i want to pass parameter to _ProductBox.cshtml. In version 3.9 i used ViewData and passed the parameter like this Html.Partial("_ProductBox", product, new ViewDataDictionary { { "p", "list" } }).

In __ProductBox I took the parameter like this: string val = this.ViewData.ContainsKey("p") ? this.ViewData["p"].ToString() : string.Empty;

Everything worked until I switched to version 4.5. In 4.5
@await Html.PartialAsync("_ProductBox", product). How to correctly pass the parameter in the new version?

Thanks.
1 ano atrás
gnikitsin wrote:
you need to overwrite RelatedProducts view component's code because it's input param is fixed

i want to pass parameter to _ProductBox.cshtml. In version 3.9 i used ViewData and passed the parameter like this Html.Partial("_ProductBox", product, new ViewDataDictionary { { "p", "list" } }).

In __ProductBox I took the parameter like this: string val = this.ViewData.ContainsKey("p") ? this.ViewData["p"].ToString() : string.Empty;

Everything worked until I switched to version 4.5. In 4.5
@await Html.PartialAsync("_ProductBox", product). How to correctly pass the parameter in the new version?

Thanks.


Please try the following approach:
@await Html.PartialAsync("_ProductBox", product, new ViewDataDictionary(this.ViewData){ { "p", "list" } })
1 ano atrás
daniel.siljanovski wrote:
you need to overwrite RelatedProducts view component's code because it's input param is fixed

i want to pass parameter to _ProductBox.cshtml. In version 3.9 i used ViewData and passed the parameter like this Html.Partial("_ProductBox", product, new ViewDataDictionary { { "p", "list" } }).

In __ProductBox I took the parameter like this: string val = this.ViewData.ContainsKey("p") ? this.ViewData["p"].ToString() : string.Empty;

Everything worked until I switched to version 4.5. In 4.5
@await Html.PartialAsync("_ProductBox", product). How to correctly pass the parameter in the new version?

Thanks.

Please try the following approach:
@await Html.PartialAsync("_ProductBox", product, new ViewDataDictionary(this.ViewData){ { "p", "list" } })


Parameter p didn't get value "list"

string val = this.ViewData.ContainsKey("p") ? this.ViewData["p"].ToString() : string.Empty;

@val empty
1 ano atrás
daniel.siljanovski wrote:
you need to overwrite RelatedProducts view component's code because it's input param is fixed

i want to pass parameter to _ProductBox.cshtml. In version 3.9 i used ViewData and passed the parameter like this Html.Partial("_ProductBox", product, new ViewDataDictionary { { "p", "list" } }).

In __ProductBox I took the parameter like this: string val = this.ViewData.ContainsKey("p") ? this.ViewData["p"].ToString() : string.Empty;

Everything worked until I switched to version 4.5. In 4.5
@await Html.PartialAsync("_ProductBox", product). How to correctly pass the parameter in the new version?

Thanks.

Please try the following approach:
@await Html.PartialAsync("_ProductBox", product, new ViewDataDictionary(this.ViewData){ { "p", "list" } })


thank. everything is working )
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.