Maintaining state between post backs using __doPostBack();

Apr 28, 2009 at 9:18 AM

Hello

 

I have a question about the Google map control. I want to use the control inside a webpart that is inside an updatepanel and remain state between postbacks. This normaly works fine. But in my website I use ’__doPostBack('UpdatePanelMain', ''); to perform a postback from javascript. This results that the control doesn’t save the state becouse the functionsave: function() {……..’ in the javascript GoogleMap3.js doesn’t get fired.

 

If I test the control with a asp:button or a html submit button it works nicely between postbacks.

Is there an event I should fire before I fire the  ‘__doPostBack('UpdatePanelMain', '');’? Or does somewone have a beter solution? I would like to keep using the__doPostBack('UpdatePanelMain', '');becouse this is already nested on many places in the webapplication. Below I have a code example how I want to use the control.

 

Thanks!

 

code example:

 

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="GoogleMapsControlTest.WebForm1" %>

 

<%@ Register Assembly="Artem.GoogleMap" Namespace="Artem.Web.UI.Controls" TagPrefix="Artem" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

 

    <script type="text/javascript">

        function test() {

            __doPostBack('UpdatePanelMain', '');

        }

    </script>

 

</head>

<body>

    <form id="form1" runat="server">

    <asp:ScriptManager ID="ScriptManager1" runat="server">

    </asp:ScriptManager>

    <div>

        <asp:UpdatePanel ID="UpdatePanelMain" runat="server">

            <ContentTemplate>

                <asp:WebPartManager ID="WebPartManager1" runat="server">

                </asp:WebPartManager>

                <asp:WebPartZone ID="WebPartZone1" runat="server">

                    <ZoneTemplate>

                        <Artem:GoogleMap ID="GoogleMap1" runat="server" Latitude="51" Longitude="5" Width="400px" Height="400px" />

                    </ZoneTemplate>

                </asp:WebPartZone>

            </ContentTemplate>

        </asp:UpdatePanel>

        <input id="Button1" type="button" value="refresh" onclick="javascript:test();" />

    </div>

    </form>

</body>

 

 

 

Coordinator
Apr 28, 2009 at 11:37 AM
Edited Apr 28, 2009 at 11:38 AM
Hi,

You can probably manually invoke save of the GoogleMap control, but that's not a good solution.
I have found where the problem is and how can be fix and work for that kind of scenarios.
That will be fixed in the final release 4.0, which is coming soon.

Regards
Coordinator
Apr 28, 2009 at 11:39 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Apr 28, 2009 at 11:58 AM

Thanks for your quick replay!

I am looking forward to the final release then. But in the meanwhile, can you give me an example how I should invoke the save?
  So I have a temporarily workaround and already can start using your control?

Regards

Coordinator
Apr 28, 2009 at 7:11 PM
Using your code above I would suggest you try next for GoogleMap Control 3.5:

<script type="text/javascript">

        function test() {
            var map = <%= GoogleMap1.ClientID %>;
            map.save();

            __doPostBack('UpdatePanelMain', '');

        }

</script>

For GoogleMap Control 4.0 beta you can do:

<script type="text/javascript">

        function test() {
             GoogleMap1.save();

            __doPostBack('UpdatePanelMain', '');

        }

</script>


Regards

Apr 29, 2009 at 9:14 AM
Hi,

Tanks for the example. This solved the problem for now!

Regards
May 4, 2009 at 7:55 AM
Hello Velio,

I've seen that ther is a new release of the googlemap control. I've tried if the problem was solved but unfortunately this is not the case.
Is there a chance this problem will be fixed in a update?

Regards