1. Renewal. (Pay attention to version issues)
Of course nbuilder. dll is also required (if you don't know what it is, check the previous one or Google it, huh, huh)
2. Drag all the aspx pages under the inputbuildertemplates folder in mvccontrib to your project views> shared
3. Create examplemodel and exampletypes.
Public class examplemodel
{
Public guid key {Get; set ;}
[Required]
Public String firstname {Get; set ;}
[Required]
Public String lastname {Get; set ;}
[Required]
[Label ("What type of example is this? ")]
Public exampletypes exampletype {Get; set ;}
[Label ("Please enter your birthday")]
[Example ("mm/DD/YYYY")]
Public datetime birthdate {Get; set ;}
[Datatype (datatype. multilinetext)]
Public String biography {Get; set ;}
}
Public Enum exampletypes
{
Man = 1,
Woman = 2,
Boy = 3,
Girl = 4,
Baby = 5
}
4. Add
Public actionresult showexample ()
{
Examplemodel model = builder <examplemodel>
. Createnew ()
. Build ();
Return view (model );
}
5. Add in Web. config
......
<Add namespace = "mvccontrib. UI"/>
<Add namespace = "mvccontrib. UI. inputbuilder. Views"/>
</Namespaces>
</Pages>
6. Do not forget to add JS references to site. master.
<SCRIPT src = ".../scripts/jquery-1.4.1.js" type = "text/JavaScript"> </SCRIPT>
<SCRIPT src = ".../scripts/jquery-ui.js" type = "text/JavaScript"> </SCRIPT>
7. Add a strong showexample View
<Fieldset>
<Legend> fields </legend>
<% Html. beginform (); %>
<% = Html. Input (M => M. Key) %>
<% = Html. Input (M => M. firstname) %>
<% = Html. Input (M => M. lastname) %>
<% = Html. Input (M => M. exampletype) %>
<% = Html. Input (M => M. Birthdate) %>
<% = Html. Input (M => M. Biography) %>
<Div style = "clear: Both;">
<Input type = "Submit" value = "Submit"/> </div>
<% Html. endform (); %>
</Fieldset>
This is already very simple. You don't need to write too much code, do you? I have tried many open-source resources such as Asp.net MVC. It seems that foreign experts like MVC.
Let's take a look at the more concise:
Add new action and view
Public actionresult new ()
{
Return view (New examplemodel ());
}
Add in newview
<% = Html. inputform () %>
OK. Is this more awesome?