Click to See Complete Forum and Search --> : Get or Post to pass value


cjbeck71081
09-15-2006, 03:24 PM
I am editing an existing asp.net structure. This is how it works...

Upon opening the map titled "BiMap.aspx" this code is accessed.


<%@ Page language="c#" %>
<%@ Import Namespace="OSGeo.MapGuide" %>
<!-- #Include File="utilityfunctions.aspx" -->

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<%
// Initialize a Aspx session and register a variable to hold the
// session id, then initialize the Web-Extensions, and connect
// to the site, and create a session.

String mapDefinition = "Library://BI/BI Map.MapDefinition";
String webLayout = "Library://BI/BIweb.WebLayout";
String sessionId = "";

try
{
//MapGuideApi.InitializeSockets();
InitializeWebTier();

MgUserInformation userInfo = new MgUserInformation("Anonymous", "");
MgSite site = new MgSite();

site.Open(userInfo);

sessionId = site.CreateSession();

//MapGuideApi.TerminateSockets();
}
catch (MgException mge)
{
Response.Write(mge.GetMessage());
Response.Write(mge.GetDetails());
//MapGuideApi.TerminateSockets();
}
%>
<%



<html>

<head>
<title>Block Island GIS</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta http-equiv="content-script-type" content="text/javascript" />
<meta http-equiv="content-style-type" content="text/css" />
<link href="styles/globalstyles.css" rel="stylesheet" type="text/css">
</head>


<frameset rows="150,*" frameborder="NO" border="0" framespacing="0">
<frame src="biborder.aspx?AppName=AJAX" name="TitleFrame" scrolling="NO" noresize>
<frame src="/mapguide/mapviewernet/ajaxviewer.aspx?SESSION=<%= sessionId %>&WEBLAYOUT=<%= webLayout %>" name="ViewerFrame">
<frame src="UntitledFrame-4"></frameset><noframes></noframes>






</html>


I accesses two framesets, one is a title frameset with some HTML in it, and the other is a compicated frameset with Asp information. The value it passes to get the application to function is the sessionID. It then passes that value over and over again, to each application to maintain the placement of the application.

What i would like to do is collect the sesionID and pass that to a new asp page, and use it to maintain the x & y location of the map, but on the new page, show completely differnt information. In order to do that, im pretty sure i need to pass the sessionID variable to the HTML frameset so when i click on the next say "Utility" page, i can then pass the variable to that page.

Here is a screenshot of the application. Any help is appreciated.

www.cbeckserver.com/viewer01.jpg

Thanks
Chris

sirpelidor
09-15-2006, 04:07 PM
your are passing ur session id through a HTTP GET in order for other aspx to read the value, what you can do is set it as session.

e.g:

Session["sessionID"] = site.CreateSession();


so for your utilities.aspx, to read the value, all u gotta do is retreive from ur session and you should be able to do whatever you want to do with the value.

e.g:

string sessionId = (String) Session["sessionID"];

cjbeck71081
09-15-2006, 04:21 PM
where should **** code reside, for it to function properly, in either page... assume that the code i placed in the forum is the code for both places.

The first page is an ASPX file with a session ID, i want to pass it to the HTML Button, which will then pass it down to the next ASPX file...


bimap.ASPX--(sessionID)--->HTML button---(sessionID)-->utility.ASPX

sirpelidor
09-15-2006, 08:54 PM
put it in a line after: sessionId = site.CreateSession(); should do the trick.

A side note, this a bad programming practice, but when one only concern making things work. That should be enough.

cjbeck71081
09-18-2006, 03:30 PM
I had no luck with passing the variable using the Session... it came up with an error. I think ulitimately the problem is that its an AJAX viewer and the session ID may not be stored right in the ASP page.

sirpelidor
09-18-2006, 06:11 PM
I had no luck with passing the variable using the Session... it came up with an error. I think ulitimately the problem is that its an AJAX viewer and the session ID may not be stored right in the ASP page.


if you look at your own code:

<frame src="/mapguide/mapviewernet/ajaxviewer.aspx?SESSION=<%= sessionId %>&WEBLAYOUT=<%= webLayout %>" name="ViewerFrame">

you are passing a variable through a HTTP GET method to ajaxviewer.aspx. And sessionId obviously is a string.

now lets look at the code where u get sessionId:

sessionId = site.CreateSession();


where CreateSession() is a method off your MgSite object. We know CreateSession() returns a string because you were able to assign to sessionId, and sessionId is come from:

String sessionId = "";



now... after a long review what's happening ur your page, lets look at what we can do to make your sessionId share across the entire app.

all your other pages that depends on sessionId will have the following code:

string someString = Request.QueryString["sessionId"];


if you would like to do is collect the sesionID and pass that to a new asp page, and use it to maintain the x & y location of the map, but on the new page, show completely differnt information. All you need to do is:


try
{
InitializeWebTier();
MgUserInformation userInfo = new MgUserInformation("Anonymous", "");
MgSite site = new MgSite();
site.Open(userInfo);
sessionId = site.CreateSession();
Session["sessionID"] = site.CreateSession();
}


now go ahead and create your own new page, do whatever u wanna do with your logic. Then when you need that sessionId, all you gotta do is:


string sessionId = (String) Session["sessionID"];