开发者

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

开发者 https://www.devze.com 2022-12-30 02:07 出处:网络
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

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

精彩评论

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