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
<globalizatio n fileEncoding="i so-8859-1" requestEncoding ="iso-8859-1"
responseEncodin g="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 ???
Two solutions:
/*
*/
// BUG encoding non UTF-8
var CS_encodeURICom ponent = encodeURICompon ent;
var CS_decodeURICom ponent = decodeURICompon ent;
encodeURICompon ent = function(s){
s = escape(s);
while (s.indexOf('/') >= 0) {
s = s.replace('/', '%2F');
}
while (s.indexOf('+') >= 0) {
s = s.replace('+', '%2B');
}
return s;
}
decodeURICompon ent = 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/Visual...dbackID=282229 two solutions recommended:
1.)using this javascript :
<script type="text/javascript">
var _encodeURICompo nent = encodeURICompon ent;
/*var*/ encodeURICompon ent = function(s){
return escape(s);
}
</script>
for me, don't work (get error) and I test this code:
var _encodeURICompo nent = encodeURICompon ent;
encodeURICompon ent = function(s)
{
return escape(s);
}
var _decodeURICompo nent = decodeURICompon ent ;
decodeURICompon ent = 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_isPa rtialLoad()) {
Sys.WebForms.Pa geRequestManage r.getInstance() .add_beginReque st(OnBeginReque st); }}
function OnBeginRequest( sender, args)
{args.get_reque st().get_header s()["Content-Type"] =
"applicatio n/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 </bodytag ??
// workaround propuesto por Microsoft. Corregido ya en ASP.net 3.5 beta 2
Sys.Application .add_load(funct ion(sender, args) {alert('pruebas
codificacion'); if (!args.get_isPa rtialLoad()) {
Sys.WebForms.Pa geRequestManage r.getInstance() .add_beginReque st(function(sen der,
args) { args.get_reques t().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
<globalizatio n fileEncoding="i so-8859-1" requestEncoding ="iso-8859-1"
responseEncodin g="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 ???
Two solutions:
/*
*/
// BUG encoding non UTF-8
var CS_encodeURICom ponent = encodeURICompon ent;
var CS_decodeURICom ponent = decodeURICompon ent;
encodeURICompon ent = function(s){
s = escape(s);
while (s.indexOf('/') >= 0) {
s = s.replace('/', '%2F');
}
while (s.indexOf('+') >= 0) {
s = s.replace('+', '%2B');
}
return s;
}
decodeURICompon ent = 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/Visual...dbackID=282229 two solutions recommended:
1.)using this javascript :
<script type="text/javascript">
var _encodeURICompo nent = encodeURICompon ent;
/*var*/ encodeURICompon ent = function(s){
return escape(s);
}
</script>
for me, don't work (get error) and I test this code:
var _encodeURICompo nent = encodeURICompon ent;
encodeURICompon ent = function(s)
{
return escape(s);
}
var _decodeURICompo nent = decodeURICompon ent ;
decodeURICompon ent = 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_isPa rtialLoad()) {
Sys.WebForms.Pa geRequestManage r.getInstance() .add_beginReque st(OnBeginReque st); }}
function OnBeginRequest( sender, args)
{args.get_reque st().get_header s()["Content-Type"] =
"applicatio n/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 </bodytag ??
// workaround propuesto por Microsoft. Corregido ya en ASP.net 3.5 beta 2
Sys.Application .add_load(funct ion(sender, args) {alert('pruebas
codificacion'); if (!args.get_isPa rtialLoad()) {
Sys.WebForms.Pa geRequestManage r.getInstance() .add_beginReque st(function(sen der,
args) { args.get_reques t().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
--