santosh kumar patro
santosh kumar patro

Reputation: 8241

Html helper for textbox using asp.net mvc3

I am trying to replace the following html textbox using html helpers for asp.net mvc3 application.

<input name="Name" id="add-student-name" type="text" maxlength="50" />

I tried with the following but on rendering I found it is not matching with the above html markup.

@Html.TextBox("Name", new {id="add-student-name", maxlength="50"})

Can anyone help me to resolve the above issue?

Upvotes: 0

Views: 1459

Answers (1)

Mikey Hogarth
Mikey Hogarth

Reputation: 4702

Add null as the second argument (your html attributes go in as the third argument)

@Html.TextBox("Name", null, new {id="add-student-name", maxlength="50"})

Been a few years since I did asp.net but I'm pretty sure that'll turn out to be your issue.

Upvotes: 2

Related Questions