I have been googling for a few hours. But still not able to get the answer. I need to get a query string parameter in a razor view.
Here is my code:
if @(Request.Query["value"]=="P"){
<a href="@Url.Action("Index", "Staff",new { status = "A"})"><strong>Active (@ViewData["activeCount"]) </strong></a>
<a href="@Url.Action("Index", "Staff",new { status = "I" })">In-Active (@ViewData["inActiveCount"])</a>
<a href="@Url.Action("Index", "Staff",new { status = "D" })">Delete (@ViewData["deleteCount"])</a>
}else{
<a href="@Url.Action("Index", "Staff",new { status = "A"})">Active (@ViewData["activeCount"])</a>
<a href="@Url.Action("Index", "Staff",new { status = "I" })"><strong>In-Active (@ViewData["inActiveCount"])<strong></a>
<a href="@Url.Action("Index", "Staff",new { status = "D" })">Delete (@ViewData["deleteCount"])</a>
}
But i get the error "The name 'Request' does not exist in the current context"
The screenshot Anyone got solution? Thanks
Use Context.Request.Query["value"]
rather than Request.Query["value"]
Yes you finally can. The answer is Context.Request.Query ["value"]
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