1

我正在开发一个网络应用程序,并且我的 vb.net 代码在网络表单中工作,只在我的控件中加载设置一次。但我使用的是谷歌地图控件,每次我的计时器运行时,该控件都会重新加载它的设置并清除我推入的任何数据。我想我需要在 asp.net/html 方面提供一些帮助才能停止回发重新加载控制。

这是我的 asp.net/html 代码。

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table style="width:100%;">
    <tr>
        <td style="width: 668px">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>




<artem:GoogleMap ID="GoogleMap1" runat="server"

    DefaultAddress="999 main st, new york NY, 10541" 
    EnableMapTypeControl="True" EnableOverviewMapControl="False" 
    EnableReverseGeocoding="True" EnableStreetViewControl="False" MapType="Roadmap" 
    MaxZoom="25" MinZoom="12" ShowTraffic="False" Zoom="18" Height="380px" 
    Width="550px" Key="13123123132132132132132123" >
</artem:GoogleMap>
<br />
        </td>
        <td>
            <asp:Button ID="Button1" runat="server" Text="Button" />
            <br />
            <br />

        </td>

    </tr>
  <tr>
  <td style="width: 668px">
  <asp:GridView ID="GridView1" runat="server">
            </asp:GridView>
      <asp:Timer ID="tmUpdateAlarms" runat="server" Enabled="False" Interval="30000">
      </asp:Timer>
  </td>
  </tr>
</table>

我的计时器代码

 Protected Sub tmUpdateAlarms_Tick(sender As Object, e As System.EventArgs) Handles tmUpdateAlarms.Tick
    tmUpdateAlarms.Enabled = False
    Try
        Dim lqFireFighterconnect As New lqFireFighterConnectDataContext
        Dim lqGetAlarms As New lqAlarmAndGoDataContext
        Dim getDeptGUID = From r In lqFireFighterconnect.tbDeptToPublics
                          Where r.PublicGUID = Request.QueryString("PUBGUID")
                          Select r
        If getDeptGUID.Count = 0 Then
            Exit Sub
        End If
        For Each foundGUID In getDeptGUID.Take(1)
            gotDeptGUID = foundGUID.DeptGUID
        Next
        Dim GetAlarms = From r In lqGetAlarms.AlarmDrops
                            Where r.DeptGUID = gotDeptGUID
                            Order By r.TimeDate Descending
                            Select r
        If GetAlarms.Count = 0 Then
            Exit Sub
        End If
        Dim myCBTable As New DataTable()
        With myCBTable.Columns
            .Add("DateTime", GetType(String))
            .Add("Address", GetType(String))
            .Add("AlarmType", GetType(String))
            .Add("CrossStreet", GetType(String))
            .Add("Status", GetType(String)) '<<<< change the type of this column to what you actually need instead of integer.
        End With
        For Each FoundAlarm In GetAlarms.Take(1)
            If Not GridView1.Rows(0).Cells(1).Text.ToString = FoundAlarm.AlarmAddress Then
                For Each updateAlarm In GetAlarms.Take(3)
                    myCBTable.Rows.Add(updateAlarm.TimeDate.ToString, updateAlarm.AlarmAddress, updateAlarm.AlarmType, updateAlarm.AlarmCrossStreets, updateAlarm.AlarmStatus)
                Next
                With GridView1
                    .DataSource = myCBTable
                    .DataBind()
                End With
                Dim objmar As New Artem.Google.UI.Marker
                objmar.Address = GridView1.Rows(0).Cells(1).Text.ToString
                'objmar.Animation = Artem.Google.UI.MarkerAnimation.Drop
                objmar.Visible = True
                objmar.Title = GridView1.Rows(0).Cells(1).Text.ToString
                objmar.Icon = "/Images/fire_c.png"
                GoogleMap1.Markers.Add(objmar)
                objmar = Nothing
                GoogleMap1.Address = GridView1.Rows(0).Cells(1).Text.ToString
            End If
        Next

        '  LoadHydrants()
    Catch ex As Exception

    End Try

    tmUpdateAlarms.Enabled = True
End Sub
4

1 回答 1

0
 <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
             <ContentTemplate>
              <artem:GoogleMap ID="GoogleMap1" runat="server"

    DefaultAddress="999 main st, New York ny, 10541" 
    EnableMapTypeControl="True" EnableOverviewMapControl="False" 
    EnableReverseGeocoding="True" EnableStreetViewControl="False" MapType="Roadmap" 
    MaxZoom="25" MinZoom="12" ShowTraffic="False" Zoom="18" Height="380px" 
    Width="550px" Key="1231231231231231231231321231313213" >
</artem:GoogleMap>
              </ContentTemplate>
            </asp:UpdatePanel>
于 2012-10-26T18:22:52.900 回答