4

I have one question regarding MVC (I am new to MVC)
My question is

In MVC with Razor for textbox we write like this

@Html.TextBoxFor(m=>m.name)

Now suppose I don't want to use Razor and html helper class. I want simple html input, like this

<input type="text" name='@Model.name' value='@Model.name'>

Is the above possible somehow?

6
  • karthik thanks for replay ,but i have try above but its not work. Commented Mar 25, 2013 at 4:34
  • 4
    What are you trying to do that you wouldn't want Model binding? I ask since you say you are new to MVC, there may be a misconception. To answer your question though, yes, you can just write HTML. If the name attribute that you give it matches a property name in the model that the server accepts on its post back, then the binding would occur. So you would do <input type="text" name="name" value='@Model.name'/> Commented Mar 25, 2013 at 4:36
  • 1
    Did you see any errors Commented Mar 25, 2013 at 4:36
  • 1
    @DaveA that is exactly what would be happening. I still don't understand his use case, but waiting for more info. Commented Mar 25, 2013 at 4:38
  • 1
    @Sagarpatel you cannot bind the way you have used in the post. Check out the comment from user(tostringtheory) which helps Commented Mar 25, 2013 at 4:51

1 Answer 1

14

you can use

<input type="text" name='@Html.NameFor(x => x.name)' value='@Model.name'>
Sign up to request clarification or add additional context in comments.

Comments

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.