How to pass parameters or data to a partial view in ASP.NET MVC

Pass value in Your Partial view as below

@Html.Partial(“~/PathToYourView.cshtml”, null, new ViewDataDictionary { { “VariableName”, “some value” } })

Retrieve the passed in values inside partial view:

@{ string valuePassedIn = this.ViewData.ContainsKey(“VariableName”) ? this.ViewData[“VariableName”].ToString() : string.Empty; }

Leave a comment