Reputation: 16959
If I do this in javascript
document.attributes["Test"] ='1';
How can I access that in ASP.NET server side code?
I looked for Attributes
on this.Page
, but it wasn't there.
Upvotes: 0
Views: 259
Reputation: 9224
Document attributes aren't posted back to the server.
What I do is add a hidden server control, then update that hidden control in javascript. That will be posted back to the server, and can be accessed.
This would be the server control. (note the clientidmode attribute, this is so that I can easily access this control in javascript)
<asp:HiddenField runat="server" ClientIDMode="Static" ID="hdnTest"/>
Then in javascript
document.getElementById("hdnTest").value = '1';
And to access it in the codebehind
hdnTest.Value
Upvotes: 3