Passing variable from one ASP to another

MCEGuide

Active Member
Joined
May 16, 2008
Messages
44
Reaction score
0
Hi

I'm trying to pass a variable from one ASP to a second ASP file but don't exactly know how to do it.

For example, with the following code you assign id a value of 1 and then pass it on:

http://www.domain.com/page1.asp?id=1

But I don't know what the value of id would be as it will change everytime. So I receive id as a variable in the first page and want to pass it onto the second page as is.

How do I go about in doing that?
 
I haven't used ASP yet but I have used aspx (C#) website perhaps it's similar:

Here's the method I wrote, please keep in mind this was for a 1st year project so the quality is a bit low :p (I've improved at least ;) )

Code:
    private string GetVar(string _var)
    {
        string QueryString = Server.HtmlDecode(Page.ClientQueryString);
        string[] Queries = QueryString.Split(';', '=');
        int QueryCount = 0;
        foreach (String Query in Queries)
        {
            if (Query.Trim().Equals(_var)) // use Query.Trim().ToUpper().Equals(_var.ToUpper()) if case shouldn't matter
            {
                if ((QueryCount + 1) < Queries.Length)
                {
                    try
                    {
                        return (Queries[QueryCount + 1]);
                    }
                    catch (Exception)
                    {
                        return null; //exception here
                    }
                }
            }
            QueryCount++;
        }
        return null; //exception here
    }

EDIT: Yes I know the for each loop is terrible in this case, I just discovered it (back then) and thought it was the shiz, so yeah my bad :p
 
Last edited:
Okay I'm a total noob when it comes to this so I really have no clue as to how your script works.

To give you a better idea of what I want, this is how my script looks like:

Code:
<%

Dim clientId
clientId = Request.QueryString.Item("clientId")

Dim postal
postal = Request.QueryString.Item("geographicId")

Response.Clear
Response.ContentType = "text/xml"
		
select case clientId
	case "085"
		consumeWebService "https://www.domain.com/GetHeadendList.asp?geographicId=0000"
	case else
		consumeWebService "https://www.domain.com/GetHeadendListError.asp"
%>

As you can see, if I specify the geographicId to be 0000 then it works, but instead of passing it on with a static value, I want to basically pass on the original geographicId.
 
Last edited:
Ah ok I see what you're trying to do, I think ;)

Have you tried:

Code:
select case clientId
	case "0858f92629344c96bf4037f40065b4b7"
		consumeWebService "https://www.domain.com/GetHeadendList.asp?geographicId=" & postal
	case else
		consumeWebService "https://www.domain.com/GetHeadendListError.asp"
 
Ah man! You're a real lifesaver!

It took me just about 4 hours to get this to work and I knew it was something so small.

Thanks a million Gnome!!!
 
Top
Sign up to the MyBroadband newsletter
X