开发者

how to add default value to the textbox helper through viewdata in asp.net mvc?

i want to add default value to the html text box by the view data. t开发者_StackOverflow社区he foolwing code will give an idea wht i want to do exactly

, new { maxlength = 4 })%>

but it shows an error. plz tel me the solution for this. thank in advance....


You want to do this instead:

Html.TextBox("quantity", Html.Encode(ViewData["quantity"]), new { maxlength = 4 })

Note: I removed the scriptlet tags around your Html.Encode. Once you're inside scriptlet tags, you don't need to use them again.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜