A
Alhambra Eidos Kiquenet
Hi
I have two updatepanels on an asp.net page and when there is a postback from
one updatepanel it changes the non english characters in the other and
displays some crap instead.
Characters non english like áÃñÑnº1ªäÄà Â
display like
áÃÂñÑnº1ªäÄà Â
In the web.config file for the project I have the glopalization set to
<globalization fileEncoding="iso-8859-1" requestEncoding="iso-8859-1"
responseEncoding="iso-8859-1" />
Does anyone have any idea to fix this. I've googled this but have not found
any solution yet
Thanks in advance
What about it ?? Bug in vs2005 ??
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=282229
Two solutions:
/*
http://blogs.codes-sources.com/cyri...ug-updatepanel-et-encoding-iso-non-utf-8.aspx
http://forums.asp.net/p/1020399/1379727.aspx#1379727
*/
// BUG encoding non UTF-8
var CS_encodeURIComponent = encodeURIComponent;
var CS_decodeURIComponent = decodeURIComponent;
encodeURIComponent = function(s){
s = escape(s);
while (s.indexOf('/') >= 0) {
s = s.replace('/', '%2F');
}
while (s.indexOf('+') >= 0) {
s = s.replace('+', '%2B');
}
return s;
}
decodeURIComponent = function(s){
while (s.indexOf('%2B') >= 0) {
s = s.replace('%2B', '+');
}
while (s.indexOf('%2F') >= 0) {
s = s.replace('%2F', '/');
}
return unescape(s);
}}
In page
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=282229 two solutions recommended:
1.)using this javascript :
<script type="text/javascript">
var _encodeURIComponent = encodeURIComponent;
/*var*/ encodeURIComponent = function(s){
return escape(s);
}
</script>
for me, don't work (get error) and I test this code:
var _encodeURIComponent = encodeURIComponent;
encodeURIComponent = function(s)
{
return escape(s);
}
var _decodeURIComponent = decodeURIComponent ;
decodeURIComponent = function(s)
{
return unescape(s);
}I get error: "the state information is invalid for this page and might be
corrupted"
2.) Another solution is “workaround†(ñapa, chapuza) of Microsoft; (note:
this problem is no problem in ASP.NET 3.0, fixed yet)
Add the following javascript to your page:
function pageLoad(sender, args) { if (!args.get_isPartialLoad()) {
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(OnBeginRequest); }}
function OnBeginRequest(sender, args)
{args.get_request().get_headers()["Content-Type"] =
"application/x-www-form-urlencoded; charset=utf-8";}
It's ok for me. Another way, for me don't work perhaps because include this
javascript in file script that loads on head page (<script
src="file.js"...>). Best way before </body> tag ??
// workaround propuesto por Microsoft. Corregido ya en ASP.net 3.5 beta 2
Sys.Application.add_load(function(sender, args) {alert('pruebas
codificacion'); if (!args.get_isPartialLoad()) {
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(function(sender,
args) { args.get_request().get_headers()['Content-Type'] =
'application/x-www-form-urlencoded; charset=utf-8'; }); }});
pageLoad is good, but I would like use Sys.Application.add_load, because can
be only one pageLoad function in page aspx. (my page contains a main user
control , and this ascx contains several ascx...)
Thanks in advance
I have two updatepanels on an asp.net page and when there is a postback from
one updatepanel it changes the non english characters in the other and
displays some crap instead.
Characters non english like áÃñÑnº1ªäÄà Â
display like
áÃÂñÑnº1ªäÄà Â
In the web.config file for the project I have the glopalization set to
<globalization fileEncoding="iso-8859-1" requestEncoding="iso-8859-1"
responseEncoding="iso-8859-1" />
Does anyone have any idea to fix this. I've googled this but have not found
any solution yet
Thanks in advance
What about it ?? Bug in vs2005 ??
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=282229
Two solutions:
/*
http://blogs.codes-sources.com/cyri...ug-updatepanel-et-encoding-iso-non-utf-8.aspx
http://forums.asp.net/p/1020399/1379727.aspx#1379727
*/
// BUG encoding non UTF-8
var CS_encodeURIComponent = encodeURIComponent;
var CS_decodeURIComponent = decodeURIComponent;
encodeURIComponent = function(s){
s = escape(s);
while (s.indexOf('/') >= 0) {
s = s.replace('/', '%2F');
}
while (s.indexOf('+') >= 0) {
s = s.replace('+', '%2B');
}
return s;
}
decodeURIComponent = function(s){
while (s.indexOf('%2B') >= 0) {
s = s.replace('%2B', '+');
}
while (s.indexOf('%2F') >= 0) {
s = s.replace('%2F', '/');
}
return unescape(s);
}}
In page
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=282229 two solutions recommended:
1.)using this javascript :
<script type="text/javascript">
var _encodeURIComponent = encodeURIComponent;
/*var*/ encodeURIComponent = function(s){
return escape(s);
}
</script>
for me, don't work (get error) and I test this code:
var _encodeURIComponent = encodeURIComponent;
encodeURIComponent = function(s)
{
return escape(s);
}
var _decodeURIComponent = decodeURIComponent ;
decodeURIComponent = function(s)
{
return unescape(s);
}I get error: "the state information is invalid for this page and might be
corrupted"
2.) Another solution is “workaround†(ñapa, chapuza) of Microsoft; (note:
this problem is no problem in ASP.NET 3.0, fixed yet)
Add the following javascript to your page:
function pageLoad(sender, args) { if (!args.get_isPartialLoad()) {
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(OnBeginRequest); }}
function OnBeginRequest(sender, args)
{args.get_request().get_headers()["Content-Type"] =
"application/x-www-form-urlencoded; charset=utf-8";}
It's ok for me. Another way, for me don't work perhaps because include this
javascript in file script that loads on head page (<script
src="file.js"...>). Best way before </body> tag ??
// workaround propuesto por Microsoft. Corregido ya en ASP.net 3.5 beta 2
Sys.Application.add_load(function(sender, args) {alert('pruebas
codificacion'); if (!args.get_isPartialLoad()) {
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(function(sender,
args) { args.get_request().get_headers()['Content-Type'] =
'application/x-www-form-urlencoded; charset=utf-8'; }); }});
pageLoad is good, but I would like use Sys.Application.add_load, because can
be only one pageLoad function in page aspx. (my page contains a main user
control , and this ascx contains several ascx...)
Thanks in advance