MVC Tips n Tricks: Using a button like an action link

I had the need to display a button that works like an action link to redirect the user to a page within an Area and didn’t want to wrap the whole thing in a form just to do the redirect.  Here is what I used.  It allows the same styling and behavior as a button but redirects directly like an action link.

<input type="Submit" 
       value="Add Persona" 
       class="btn btn-primary btn-lg" 
       onclick="location.href='@Url.Action("Detail", "Persona", new { area = "ProfileInfo" })'" />

Leave a Reply

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

WordPress.com Logo

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

Google+ photo

You are commenting using your Google+ 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 )

w

Connecting to %s