Reputation: 593
I have an ASP .Net webpage, which fills a DropDownList from code behind. The value of the DropDownList is a xml value. It is working in Firefox and Chrome, but IE(IE11) loses the value, its just empty but only for the DropDownList. The other values (Textboxes) are just fine.
What is the difference between the postback value handling in Firefox, Chrome and IE?
I replaced every character in the xml string with X and it is working, IE returns the DropDownList value "xxxxxxxxxxx...". I replaced the xml string with "<>?!/&$'\"(){}[]" to see if a special character makes a problem, but even that is working. So I tried this method:
System.Security.SecurityElement.Escape();
But even with this, the postback value is empty.
In the HTML source in Internet Explorer I can see every value, the xml string, the encoded xml string, the "xxxxxxxxx..." etc. So IE takes the value and places it in the DropDownList, but if you select the xml string (or encoded xml string) and do a postback, the value of the DropDownList is empty...
Upvotes: 0
Views: 469
Reputation: 593
I found the issue, it has nothing to do with xml, it was the NewLine in the xml string. Internet Explorer can´t handle postback values which contains NewLines.
I have to replace every NewLine in the DropDownList values, now it´s working!
I am replacing the Environment.NewLine
with a dummy value <NEWLINEDUMMY/>
and after I get the postback value from the DropDownList I reverse the replace.
So first:
System.Security.SecurityElement.Escape(xmlstring).Replace(Environment.NewLine, NEWLINEDUMMY);
and then:
HttpUtility.HtmlDecode(postbackvalue).Replace(NEWLINEDUMMY, Environment.NewLine);
Upvotes: 1