MVC: Passing Query String Values Within a View

Please see my other MVC articles.

Building Links from Model Data

This article illustrates how to build a link within an MVC view which passes model data as a query string variable.

First, I begin with my “model” statement exposing my RaveUser model’s properties.

Next, I provide an ActionLink() statement with text for the link (“Reload All Values”), the name of the controller function to call (“LoadSelectedUser”), and finally, pass to the ActionLink() statement the SNumber property of the model.

As you can see, when the page displays and the Razor engine renders the HTML, the link displays as expected, passing the current user’s SNumber (1-8) as the query string value.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s