c# - asp.net mvc framework information propagation -


I have an asp page that has a form with two fields where the customer should write his information.

  & lt; Td> & Lt;% = Html.TextBox ("Date")% & gt; & Lt; / Td> & Lt; TD & gt; & Lt;% = Html.TextBox ("City")% & gt; & Lt; / TD & gt;  

The signature of my verb at this time (at this time):

  public action XXX (string date, string city) {...} < / Code> 

The problem is that I want to promote a common integral number to take action from my point of view. Is it possible to have a hidden text box or something similar?

  Public Performance CreateCourseDate (String Date, String City, Intit ID)  

There are two ways to do this, either use hidden field method (I will not recommend it) or add to URL (root value). The latter is better with the URL as the rest, which MVC likes. Therefore, if you are using a new look, your URL will look like this:

  http://example.com/course/newcoursedate/1  

It will edit with the course id 1 . You will have a create action that will be posted to your new form The examples below assume that your view has been typed strongly with a course model if necessary You can also drag ID from viewdown.

 using  & lt;% (Html.BeginForm ("CreateCourseDate", "Course", New {id = ViewData.Model.CourseID}, ... ... & lt ; Td> & lt;% = Html.TextBox ("Date")% & gt; & lt; / td> & lt; td & gt; & lt;% = Html.TextBox ("City") % & Gt; & lt; / Td> & lt;%}% & gt;  

I did not see the order of the parameter, but I believe at least one signature In order to ensure the path values ​​after the controller name, consult the source (or intellisense).


Comments