Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all...
I want to show username in textbox/textboxfor but while passing to controller on http post i want user id to be passed. How can achieve this functioanlity in mvc by any means?
Posted
Comments
deepakaitr12345 4-Sep-12 7:30am    
Just try to get the user id using the formcollection
like you have controller
public ActionResult TestController(FormCollection fc)
{
//code
fc.GetValue("textboxid" + i).AttemptedValue//this is your id value
}


Hope this will help you.

Thanks

1 solution

You need to have the model bound with your view first of all...
Then you can have TextboxFor in the View. You can directly get that using formCollection.

Try following

C#
[HttpPost]
public ActionResult Index(FormCollection formValues)
{
  string value = formValues["userName"];
  return View();
}



Hope this helps

Regards,
Sagar
 
Share this answer
 

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