[mapguide-users] OK I'm getting back to basics.... send xml to
codebehind
Jamo
adam.jamison at portbris.com.au
Wed Feb 17 00:53:58 EST 2010
I've got a production map where this is working.....
process page loads.
populate hidden variables with mapname session ID etc.
grab this information in codebehind for C# .Net fiddling......
This page replaces the properties panel
ASPX Page
<%@ Page Language="C#" ValidateRequest="false" AutoEventWireup="true"
CodeFile="propertiesPanel.aspx.cs" Inherits="propertiesPanel" %>
<!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">
<title>Properties Panel</title>
<script type="text/javascript" >
function onLoad() {
//populate hidden fields for use in codebehind
document.getElementById("sessionId").value = parent.GetSessionId();
document.getElementById("mapName").value = parent.GetMapName();
}
function SetProperties(count, properties) {
//populate hidden field with selected XML for use in codebehind
document.getElementById("selXML").value = parent.GetSelectionXML();
__doPostBack("infoPanel", "");
}
</script>
</head>
<body onload="onLoad()">
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<%--loading panel to be shown when page is being generated--%>
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<div style="background-color:White; z-index:10;
position:absolute; width:100%; height:100%; vertical-align:middle;"
id="loading" runat="server" >
<iframe frameborder="0" style="z-index:9; position:absolute;
width:100%; height:100%; vertical-align:middle;"></iframe>
<center style="position:absolute; top:100px;z-index:10;
width:100%">Update in Progress...</center>
</div>
</ProgressTemplate>
</asp:UpdateProgress>
<%--properties panel to be loaded in codebehind need to work on status
bar--%>
<asp:UpdatePanel ID="infoPanel" runat="server" >
<ContentTemplate>
<div>
<asp:Button ID="Button1" runat="server" Text="Button"
OnClick="test" />
<asp:Image runat="server" ImageUrl="../customicons/hammer.gif"
/>
<asp:Panel ID="Panel1" runat="server" ScrollBars="None"
Width="100%" >aa</asp:Panel>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<%--hidden fields for use by codebehind in Page_Load--%>
<input type="hidden" ID="count" runat="server" />
<input type="hidden" ID="selXML" runat="server" />
<input type="hidden" ID="mapName" runat="server" />
<input type="hidden" ID="sessionId" runat="server" />
</form>
</body>
</html>
CodeBehind
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OSGeo.MapGuide;
public partial class propertiesPanel : System.Web.UI.Page
{
MgSite site = new MgSite();
MgResourceService ResourceService;
MgFeatureService FeatureService;
MgRenderingService RenderService;
MgDrawingService DrawingService;
MgMappingService MappingService;
MgSiteConnection siteConnection;
MgMap map;
MgUserInformation userInfo;
protected void siteConn()
{
MapGuideApi.MgInitializeWebTier(Request.ServerVariables["APPL_PHYSICAL_PATH"]
+ "../webconfig.ini");
userInfo = new MgUserInformation(sessionId.Value);
site.Open(userInfo);
siteConnection = new MgSiteConnection();
siteConnection.Open(userInfo);
ResourceService =
siteConnection.CreateService(MgServiceType.ResourceService) as
MgResourceService;
FeatureService =
siteConnection.CreateService(MgServiceType.FeatureService) as
MgFeatureService;
RenderService =
siteConnection.CreateService(MgServiceType.RenderingService) as
MgRenderingService;
DrawingService =
siteConnection.CreateService(MgServiceType.DrawingService) as
MgDrawingService;
MappingService =
siteConnection.CreateService(MgServiceType.MappingService) as
MgMappingService;
map = new MgMap(siteConnection);
map.Open(mapName.Value);
}
protected void test(object sender, EventArgs e)
{
Label cSessionId = new Label();
cSessionId.Text = sessionId.Value;
Panel1.Controls.Add(cSessionId);
}
protected void test2()
{
Label cSessionId = new Label();
cSessionId.Text = sessionId.Value;
Panel1.Controls.Add(cSessionId);
}
protected void Page_Load(object sender, EventArgs e)
{
test2();
Label cSessionId2 = new Label();
cSessionId2.Text = "hey what the";
Panel1.Controls.Add(cSessionId2);
Label cSessionId = new Label();
cSessionId.Text = sessionId.Value;
Panel1.Controls.Add(cSessionId);
}
}
--
View this message in context: http://n2.nabble.com/OK-I-m-getting-back-to-basics-send-xml-to-codebehind-tp4584558p4584558.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list