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

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -