I'd like to be able to pass a string into my partial view from the calling View - this string will be different depending on the view from which the partial view is rendered. Something like this:
@{ Html.RenderPartial("PartialViews/_BreadcrumbsPartial", "New Item");}
Or
@{ Html.RenderPartial("PartialViews/_BreadcrumbsPartial", Model.Name);}
How can I access this second parameter from within the partial view, since I haven't labeled that parameter? I'd like to avoid passing the whole model in if possible, and just reference that string directly.
Partial Views can use the Page Model for their data whereas Child Actions use independent data from the Controller. Editor/Display templates pass items from the model to the system but can be overridden by user partial views.
Your Partial Must bind to a string
example, at top place this:
@model string
To access the value in your partial, use @Model
in place of string param
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With