Reputation: 1769
Question 1) I have a control to which I add an attribute from the server side by using a sentence like:
ControlName.Attributes.Add("myTestAttribute", "")
From the client side I modify the value of this attribute by using the Javascript function:
Document.getElementById(ControlName).setAttribute("myTestAttribute", “Hello Server!!”);
My problem is that when I try to acces to the attribute value on the Postback treatment function the attribute is empty. Am I missing some step?
Question 2) Is it possible to obtain the full HTML code of the page in the server side from inside a Postback treatment function?
Upvotes: 0
Views: 146
Reputation: 46465
If javascript modifies elemants on a page, they will not be visible to the server. When a postback occurs, the only data that is available to the server is the data that is sent in the form on the page.
ASP.net handles standard form elements such as textboxes, drop down lists etc. by putting their values into a hidden field called viewstate (this is normally encoded so cannot be read directly).
If you want page elements modified by javascript to be visible to the server, you can write new hidden form elements and retrieve them from the Request[string name] array.
Upvotes: 1
Reputation: 29157
In response to question 2, you could persist the status of these attributes in the viewstate if you wanted to know their values after a postback.
Upvotes: 0