开发者

Reading int from a hidden field in .aspx

开发者 https://www.devze.com 2022-12-31 16:37 出处:网络
I\'m struggling to read an int from the hidden field on aspx page. <input type = \"hidden\" id = \"myIntegerId\" name = \"integerId\" value= \"<%: Model.MyObjectId %>\" runat = \"server\" /&

I'm struggling to read an int from the hidden field on aspx page.

<input type = "hidden" id = "myIntegerId" name = "integerId" value= "<%: Model.MyObjectId %>" runat = "server" />

The value is definately on the form, I can see it in the debugger and print it with <%: %>

When I read the form values in the controller, instead of an int I recieve a following string: <%: Model.MyObjectId %>

I have tried casting data in the hidden field to string and calling ToString() method on that field, neith开发者_JAVA百科er has worked.

The data is submitted using the post event.

I have a feeling that I'm missing something very basic...

Any help is greately appreciated.

Thanks


Ahh, <%: String.Format("{0:g}", Model.MyObjectId) %> has done the job...

0

精彩评论

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