문제

Can you initialize the value of Html.TextBoxFor with a value in HTML5 localStorage?

I know that you can initiliaze with a string.

@Html.TextBoxFor(m=>m.name, new {@Value="John Doe"})

What if I want to use a string in localStorage instead of "John Doe"?

도움이 되었습니까?

해결책

You cant, you would have to use javascript, or create a helper which outputs the javascript for you.

if you create the helper you can use jquery:

var localStorageKey = "yourkey";
$("#textboxid").val(window.localStorage[localStorageKey]);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top