Chintu
Chintu

Reputation: 525

passing value in partial view viewdatadictionary

@Html.Partial("~/Areas/WO/Views/PartialContent/_FirstPage.cshtml", new ViewDataDictionary {  { "WOID", WOID } })

In my Page i am accessing Partial view in the above way. I need to pass WOID(view data dictionary) value from query string, For that i am using following Code

@{
   var desc = Html.ViewContext.HttpContext.Request.QueryString.Get("ID");
   Uri referrer = HttpContext.Current.Request.UrlReferrer;
   string[] query = referrer.Query.Split('=');
   int WOID = Convert.ToInt32(query[1]);
}

But the issue is this code is working in all browsers except I.E. i Need to Solve this problem. Please help me

Upvotes: 0

Views: 465

Answers (1)

Jags
Jags

Reputation: 782

Instead of this you can have this value as part of you model and use that.That is the standard and recommeded way .

In your action method you can have these as parameter.Your query string value will get bind to this parameter

public ActionResult ActionMethod(int ID)
{
Model.WOID = WOID;
  // Other logic
  return View(Model)
}

Next step you can add this as a property to your view model or add it to ViewData dictionary and then access it in your partial view.

Upvotes: 1

Related Questions