开发者

Can I post-back <asp:HiddenField>'s value modified with JS

As title, would this raise the same开发者_运维问答 problem like Invalid postback or callback argument. Event validation is enabled using '<pages enableEventValidation="true"/>' ?

Thank you


No, no exception will be raised, you can safely post with a value changed using JavaScript. I have personally used that approach to persist some important information across the postbacks. Example code:

Sys.Application.add_load(function() {
            document.getElementById("HiddenField").value = "This value is going to be persisted across the postbacks";
        });



<asp:HiddenField runat="server" ID="HiddenField" />


Yes.

According to http://msdn.microsoft.com/en-us/magazine/cc163512.aspx

The page basically matches the contents of the request with the information in the __EVENTVALIDATION field to verify that no extra input field has been added on the client and that value is selected on a list that was already known on the server.

So this won't violate either of the rules.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜