Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The method for passing the ID using @Html.Partial in ASP.NET MVC is by passing the ID as a parameter to the partial view, like this:

@Html.Partial("_PartialViewName", ID)

Then in the partial view, you can access the ID using the model, like this:

@model int
<p>My ID is @Model</p>

Alternatively, you can store the ID in the Http session and retrieve it in the partial view like this:

@{
    int ID = (int)Session["ID"];
}
@Html.Partial("_PartialViewName", ID)

Then in the partial view, you can access the ID like before, using the model. However, this method requires that you have set the ID in the Http session before calling the partial view.