For example I am on page http://localhost:1338/category/category1?view=list&min-price=0&max-price=100
And in my view I want to render some form
@using(Html.BeginForm("Action", "Controller", new RouteValueDictionary { { /*this is poblem place*/ } }, FormMethod.Get))
{
<!--Render some controls-->
<input type="submit" value="OK" />
}
What I want is to get view
parameter value from current page link to use it for constructing form get request. I tried @using(Html.BeginForm("Action", "Controller", new RouteValueDictionary { { "view", ViewContext.RouteData.Values["view"] } }, FormMethod.Get))
but it doesn't help.
I've found the solution in this thread
@(ViewContext.RouteData.Values["view"])
You should still have access to the Request object from within the view:
@using(Html.BeginForm(
"Action",
"Controller",
new RouteValueDictionary {
{ "view", Request.QueryString["view"] } }, FormMethod.Get))
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