Click here to Skip to main content
15,891,721 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi
I started an MVC application and I modified the standard registration process (I use Identity 2.0 and plan also to extend with OWin)
I added fields to AspNetUsers table, I adapted all necessary to new information I capture and all it works.
What I want and don't know how to do is to add in navigation two @Html.ActionLink items that points to the same Registration view, but each passing a different value as parameter for Role (e.g. one link to send value 2 meaning for me candidate, other value 3 meaning employer; at least that I want to save in table). Also I want if possible to conditionally display fields in form regarding to parameter value (e.g. if Role value is 2 to display Birthday fields, if 3 to display Companyname and so on).
Also I want to save also at same form send the just created UserID (how to capture it) and the Role that come as parameter in the table AspNetUserRoles, that have as fields UserID and RoleID

Thank you for any hint.
Posted

1 solution

Look at any documentation or tutorial for ActionLink and it will explain how you pass parameters

@Html.ActionLink("Click", "MyAction", "MyController", new { role = 2 }, null)


That will add "?role=2" to the url, and your action will need to be able to bind to the "role" param in order for it to be populated, eg

public ActionResult MyAction(int role)
{
//
}


Conditionally displaying things, saving data, passing data to actions etc are all basic aspects of MVC, and a forum isn't the best place to learn these things. Go through some proper MVC tutorials and they'll explain all the basics

http://www.asp.net/mvc[^]

http://www.asp.net/mvc/overview/older-versions/mvc-music-store/mvc-music-store-part-1[^]
 
Share this answer
 
Comments
Laurentiu LAZAR 29-Apr-15 12:28pm    
Thank you.

I miss the action parameter.
Laurentiu LAZAR 29-Apr-15 14:44pm    
In what concerns tutorial from asp.net I find them nearly useless. They cover far from real life scenarios. Or maybe I don't know how to read them.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900