This project is read-only.

Server-Side events and property persistence in UpdatePanel for v3.3

May 14, 2008 at 5:30 PM
Hi,
I have made the following changes in the source files to get serverside events and persisting properties during UpdatePanel Postback to work.
Maybe there should be some cleanup code somewhere to prevent memory leaks but in principle this works and i hope it helps in the development
efforts of this great control.

in GoogleMap.EventList.cs, ToJsonString() at line 145:
---------------------------------------------------------------
if (HasClientEvents)
{ ... }
else buff.Append("\"ClientEvents\":[]");

in GoogleMap3.debug.js, Artem.Web.GoogleMap.prototype, load at line 726:
------------------------------------------------------------------------------------------
load: function(point) {
if(point) {
} else {
    // get page request manager
    var manager = null;
    if (Sys && Sys.WebForms && Sys.WebForms.PageRequestManager)
        manager = Sys.WebForms.PageRequestManager.getInstance();
    // use submit or ajax for persisting state
    if( manager ) manager.add_beginRequest( Artem.Web.Delegate.create(this, this.savepartial) );
    else document.forms[0].onsubmit = Artem.Web.Delegate.create(this, this.save);

    if((this.Latitude != 0) && (this.Longitude != 0))
    ....
}

in GoogleMap3.debug.js, Artem.Web.GoogleMap.prototype, added function at line 726:
-------------------------------------------------------------------------------------------------------

savepartial:
function(sender,args)
{
    
// save into hidden field
    this.save();
    // get from hidden field
    
var bag = document.getElementById(this.ClientID + "_State");
    
var state = bag.value;
    
var request = args.get_request();
    
var body = request.get_body();
    
var token = "&" + this.ClientID + "_State=";
    
// convert to postback format
    
state = escape(state);
    state = state.replace(
"+", "%2B");
    state = state.replace(
"/", "%2F"); 
    // replace body
    
body = body.replace(token, token + state);
    request.set_body(body);
},

 

May 14, 2008 at 6:26 PM
And just found out for the server side marker events

in GoogleMarker.EventList.cs, ToJsonString():
---------------------------------------------------------------
if (HasClientEvents)
{ ... }
else buff.Append("\"ClientEvents\":[]");
May 14, 2008 at 9:31 PM
And just found out for the server side marker events

in GoogleMarker.EventList.cs, ToJsonString():
---------------------------------------------------------------
if (HasClientEvents)
{ ... }
else buff.Append("\"ClientEvents\":[]");
May 15, 2008 at 4:12 AM
Hi, i just did't and i tested with a summit button. do you have a sample that it should be with ajax?
Thank you
May 15, 2008 at 8:35 AM
Thank you,

The "problem" is if the asp.net page contains ajax, the control must be in a updatepanel, for me these lines is the solution :

Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(Artem.Web.Delegate.create(this, this.savepartial));
document.forms[0].onsubmit = Artem.Web.Delegate.create(this, this.save);

May 15, 2008 at 6:43 PM
And just found out for the server side marker events

in GoogleMarker.EventList.cs, ToJsonString():
---------------------------------------------------------------
if (HasClientEvents)
{ ... }
else buff.Append("\"ClientEvents\":[]");
May 17, 2008 at 3:42 AM


ClementL wrote:
Thank you,

The "problem" is if the asp.net page contains ajax, the control must be in a updatepanel, for me these lines is the solution :

Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(Artem.Web.Delegate.create(this, this.savepartial));
document.forms[0].onsubmit = Artem.Web.Delegate.create(this, this.save);




Hello Again, and thank you for answer,
my excuses to bothering  you again, but I just don't figure it out how and where I should add those lines, if you could reply with a simple sample will be nice.
Thank you anyway.
Regards.
May 19, 2008 at 8:40 AM
Same lines as the first solution :

in GoogleMap3.debug.js, Artem.Web.GoogleMap.prototype, load at line 726:
------------------------------------------------------------------------------------------
load: function(point) {
if(point) {
} else {
    // get page request manager
   Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(Artem.Web.Delegate.create(this, this.savepartial));
   document.forms[0].onsubmit = Artem.Web.Delegate.create(this, this.save);

    if((this.Latitude != 0) && (this.Longitude != 0))
    ....
}

May 21, 2008 at 10:11 AM


ClementL wrote:
Same lines as the first solution :

in GoogleMap3.debug.js, Artem.Web.GoogleMap.prototype, load at line 726:
------------------------------------------------------------------------------------------
load: function(point) {
if(point) {
} else {
    // get page request manager
   Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(Artem.Web.Delegate.create(this, this.savepartial));
   document.forms[0].onsubmit = Artem.Web.Delegate.create(this, this.save);

    if((this.Latitude != 0) && (this.Longitude != 0))
    ....
}
Nice job ClementL,
I was persisting in getting  those properties in my update panel triggered by an AJAXS Timer and fired up a postback by tick event,
I'm get riddle of those AJAXS and raise an event  by an asp: Timer in  the page load event normally and it's working just &%$& well, thank you.
P.D. I still wonder, if this could be made inside of the update panel will be nice.
Maybe Velio or yourself could be done this.
And Thank you Velio. Nice job