c# - Prefix 0 in Razor Textbox value -


here razor text box

@html.textboxfor(model => model.shortbufferhour,new { @maxlength = "2",style="text-align:center;"}) 

it shows hours 7. how prefix 0 in case of single digit hour. textbox content 07

you need use d2 format option , pass value through html atttribute:

this can done follows:

@html.textboxfor(model => model.shortbufferhour, new { @maxlength = "2",style="text-align:center;", value=string.format("{0:d2}",model.shortbufferhour) }) 

Comments

Popular posts from this blog

rdbms - what exactly the undo information lives in oracle? -

bash - How do you programmatically add a bats test? -

java - Getting exception in JDBC thin driver -