1

i am new in MVC and try to learning through googling & online tutorial. i search Form binding with Model sample in MVC and got many sample code but i am not getting a sample code for a complete form where all kind of html controls are used like

checkbox
radiobutton
listbox control
drodownlist
textarea
hiddenfields
checkboxlist
radiobuttonlist etc

and all controls should be bind through model with server side and client side both kind of validation. form should have two textbox one dropdown, 3 checkboxes and 2 radio button, one listbox control and if possible provide guide line to work with checkboxlist & radiolist.

if anyone knows that kind of url then plzz inform me or if possible please give me a sample code of a complete form where all the above controls will be there with model binding and validation. thanks

2 Answers 2

2

in the Views there is a helper called Html you can use it in the view like @Html

there are all things that you wanted, for example

@Html.HiddenFor

@Html.RadioButtonFor

@Html.TextAreaFor

and so on

search for asp.net mvc Html helpers

another smaple

@Html.CheckBox("sameName")
@Html.CheckBox("sameName")
@Html.CheckBox("sameName")
@Html.CheckBox("sameName")

it will produce this html

<input type="checkbox" name="sameName" />
<input type="checkbox" name="sameName" />
<input type="checkbox" name="sameName" />
<input type="checkbox" name="sameName" />

take a look at this website

Sign up to request clarification or add additional context in comments.

4 Comments

is there anything for checkboxes,listbox, i can have multiple set of checkboxes then how can i specify group name and divide accordingly.
i have edit the answer with another sample, if you want to change html attributes just look for other overloads of the helper
thanks. i am new and that is why like to request u that if possible please give me a sample code of a complete form where all kind of html controls will be there and bind through model. it is my request. thanks once again.
u can also give me a link where i can get desire form with model binded. thanks
1

Have a look here:

It Explains, Rendering a Form in ASP.NET MVC Using HTML Helpers

http://msdn.microsoft.com/en-us/library/dd410596%28v=vs.100%29.aspx

http://stephenwalther.com/archive/2009/03/03/chapter-6-understanding-html-helpers

2 Comments

can give me a link/url from where i can get desire form with all kind of html controls with model bind. thanks
@Thomas see 2nd link.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.