Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 22nd, 2004, 01:23 AM
Authorized User
 
Join Date: May 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Passing values between Aspx page to Asp page.

I am using my Login Page as Aspx Page and my menu page is in Asp and Javascript Page.
So i want to pass variables from aspx Page to Asp Page.
Also i am in need of getting values from Asp page to Aspx Page.
(like Passing Session variable)
Also pass these variables throughout the Software.
It is a Aspx Application Software.
Is it possible? How?

Pls... explain in breif.
With Regards
Jayaraj
 
Old May 22nd, 2004, 08:42 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

http://p2p.wrox.com/topic.asp?TOPIC_ID=13873
 
Old May 23rd, 2004, 06:34 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

In brief: you can't use the session. The session for each technology (ASP vs. ASPX) are not shared. Each technology runs in a different process so they are completely isolated. You will need to hand values back and forth between the two using the querystring, cookies or a combination of either of those and a database. You could have a cookie to identify a user and create your of database driven session managment system. Cookies can work between the two technologies, so you can carry around the session identifier that way.

Peter
-------------------------
Work smarter, not harder
 
Old May 23rd, 2004, 11:23 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

use <form> & [u]Request.Form</u> or [u]Request.WuesryString</u>.
U can NOT use Session between ASP & ASPX as Peter said.

Always:),
Hovik Melkomian.
 
Old June 9th, 2004, 12:31 AM
Authorized User
 
Join Date: Aug 2003
Posts: 18
Thanks: 0
Thanked 1 Time in 1 Post
Default

Here's something that might pique your interest. I maintain an OBJECT on the client I pass to the server through a hidden text box on the form (I don't want it in a querystring -- plus the length of a querystring is limited). Obviously since you can't send an object in a hidden textbox, you must convert the object to a string first and then put it in the hidden textbox.

To get the object on the client in the first place, I create javascript code and response.write it out inside a <script></script> tag on the client. Something like response.write("function myObject(){this.Token;this.username} var token=new myObject();") I typically do this in code behind, but is can be old style server side ASP too. This puts the object initially on the client.

I also include a javascript file <script src="uneval.js"></script> on the client that contains code that I am putting at the bottom of my post called "uneval"; What this does is decompose any object into the javascript commands (and values) that would programmatically recreate the object (and data) if executed. The output of this function is an escaped string (of javascript commands) that I stick in the hidden textbox on the form that can be posted to the server. The next page simply uses response.write("var token="+Request.FORM("hiddenTextBoxID") back to the client.

On the client, to recreate the object you simply use the eval command like var token=eval(token); The eval command executes the code generated by my uneval function and recreates the original object on the client complete with data. Note, this is designed to work with any function and should work for you like it is.

Hubman
--------------------------
//*************************
// UNEVALUATE FUNCTIONALITY
// These functions take a given jscript object and create a
// string representing the object instance in its current state,
// such that when the string is "evaluated" with the "eval"
// function, the object will be recreated. The uneval function is used
// to to "marshall" jscript objects across the client/server
// boundary. Note: unevaluated objects do not need to be 'escaped' (safe to transmit as-is)
//
var __reFunction = /function ([^\(]*)\(([^\)]*)\)[^\{]*([^$]*)/i; // function $1=name, $2=args, $3=body
var __nextObjID = 0;
var __getNextObjID = new Function('return("_o_"+(__nextObjID++));');
var __unevaledObjects; // array to track unevaluated objects

function uneval(obj,isNested)
{
    var str = "";
    if (!isNested) // then starting up
        __unevaledObjects = new Array(); // reset tracking array of which objects unevaluated
    switch (typeof(obj))
    {
        case 'undefined':
            str = "undefined";
            break;
        case 'boolean':
        case 'number':
            str = obj.toString();
            break;
        case 'string':
            str = 'unescape("'+escape(obj)+'")';
            break;
        case 'function':
            if (obj.__unevalID) // manage multiple references to same function
                return(obj.__unevalID);
            var fnMatch = obj.toString().match(__reFunction); // split apart function definition
            if (fnMatch)
            {
                var objID = "myToken"; //__getNextObjID(); -- cbh
                obj.__unevalID = objID;
                __unevaledObjects[__unevaledObjects.length] = obj; // save reference to object for later clean-up
                str = "var "+objID+"=new Function(";
                var args = fnMatch[2].split(",");
                for (var i = 0; i < args.length; i++)
                    str += '"' + args[i] + '",';
                str += 'unescape("'+escape(fnMatch[3])+'"));';
                str += objID+";";
            }
            break;
        case 'object':
            if (obj == null)
                return("null");
            if (typeof(obj.getTime) == "function") // then date object
            {
                str = "new Date("+obj.getTime()+");";
                break;
            }
            if (typeof(obj.substring) == "function") // then string object
            {
                str = 'new String(unescape("'+escape(obj.valueOf())+'"));';
                break;
            }
            if (obj.__unevalID) // prevent endless loops (manage recursive references)
                return(obj.__unevalID);
            else // array or custom object
            {
                var property,last,ele;
                var len = obj.length;
                var objID = "myToken"; //__getNextObjID(); -- cbh
                obj.__unevalID = objID; // add property to allow proper handling of cyclic references
                __unevaledObjects[__unevaledObjects.length] = obj; // save reference to object for later clean-up
                if (obj.constructor == Array) // then array (has automatic length property)
                    str = "var "+objID+"=new Array();";
                else // object
                    str = "var "+objID+"=new Object();";
                //str = "var "+objID+"=new Object();";
                for (ele in obj)
                {
                    if (ele == "__unevalID") // skip this (internal use only)
                        continue;
                    property = uneval(obj[ele],true);
                    if (property)
                    {
                        if (property.charAt(property.length-1) == ";") // then object property returned
                        {
                            last = property.lastIndexOf("_o_");
                            str += property.substring(0,last);
                            property = property.substring(last,property.length-1);
                        }

                        str += objID+"['"+ele+"']="+property+";";
                    }
                }
                str += objID+";";
            }
        break;
    }
    if (!isNested) // then doing final exit, so clean up
    {
        for (var xx=0; xx < __unevaledObjects.length; xx++) // remove temporary property that marked unevaluated objects and functions
            delete(__unevaledObjects[xx].__unevalID);
    }
    return (str);
}
//
// END UNEVAL





Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing values between Asp to Aspx page jayaraj General .NET 2 May 25th, 2004 01:16 AM
How to pass variables from Aspx page to Asp Page jayaraj Classic ASP Basics 2 May 23rd, 2004 06:56 AM
Passing values between Asp to Aspx page jayaraj VS.NET 2002/2003 2 May 23rd, 2004 06:54 AM
passing values from ASP page to a popup ASP Page astrosmurfboy Classic ASP Basics 3 April 21st, 2004 08:17 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.