MVC3 Razor Dynamic creating forms?

Up vote 0 down vote favorite share g+ share fb share tw.

First I want to point out Im very new to this area ^_^ . Anyhow I'm doing a project with a grade-reporting system and now Im currently working with the cshtml for the update of usertask. My problem is I'm currently working with trying to add a form post but it's not really working at all.

To my view I have a model with a list of usertasks (and other data). These usertasks contains int id and string grade. What I am trying to do is foreach usertask create a form with their own submit button.

The form would have a hidden field for id and a textbox for grading. The problem I have with @Html. Hidden Compiler Error Message: CS1973: 'System.Web.Mvc.

HtmlHelper' has no applicable method named 'Hidden' but appears to have an extension method by that name. Extension methods cannot be dynamically dispatched. Consider casting the dynamic arguments or calling the extension method without the extension method syntax.

Which I assume is you cant dynamicaly use Html. Hidden (i use a foreach loop over the list of usertasks). Anyone have any idea how to solve this?

I've been thinking about creating partialviews but couldnt figure out if you could pass paramters to them. Or make the submit button redirect to a controller-view which takes the 2 paramters? Anyone have any examples?

Thx for help! Submitting some code I have been trying to get to work. Foreach (var tskModel in tskgrpModel.

Usertasks) { @tskModel. Name using (Html. BeginForm("Update", "Teacher", FormMethod.

Post)) { if(tskModel. IsSet == true) { @Html. Hidden("ut_id", tskModel.

Id ) @Html. TextBox("ut_grade",(string)@tskModel. Grading); } else { @Html.

Hidden("ut_id", -1) @Html. Hidden("ut_id", "NotSet") } } } asp.net forms asp.net-mvc-3 razor link|improve this question asked Apr 18 '11 at 22:54James Hau11.

Is taskModel. Id a dynamic variable? If so change the line @Html.

Hidden("ut_id", tskModel. Id ) to @Html. Hidden("ut_id", (int) tskModel.

Id ).

I think I didn't explain thorougly. What I want do know is how to create a form which has fields from a List where each usertask has a string property grading. And When I submit I want to in some easy way know which of the UserTasks ( they have uniqe ids) I changed the grading for.

– James Hau Apr 19 '11 at 15:34 Nvm figured out a way – James Hau Apr 20 '11 at 19:33.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions