1

on page A

 test.Controls.Add(GetButton(thisReader["session_name"].ToString(), "Join Session"));

Response.Redirect("EnterSession.aspx?session=" + e.CommandArgument.ToString());

on page B

 _gaq.push(['pageTrackerTime._trackEvent', 'category', 'action', document.location.href, roundleaveSiteEnd]);

when a user clicks a button on page A , he will be directed to page B and there I used document.location.href to track the current URL. now I would like to track as well session_name from page A using JavaScript.

how can I do this

the original code was like this

SqlCommand thisCommand = thisConnection.CreateCommand();
                thisCommand.CommandText = "SELECT * FROM Tmyapp_Session;";
                SqlDataReader thisReader = thisCommand.ExecuteReader();

                while (thisReader.Read())
                {
                    test.Controls.Add(GetLabel(thisReader["session_id"].ToString(), thisReader["session_name"].ToString()));
                    string[] compare = secondResult.Split(';');
                    foreach (string word in compare)
                    {
                        if (word == thisReader["session_id"].ToString())

                        {
                            test.Controls.Add(GetButton(thisReader["session_id"].ToString(), "Join Session"));

I had to change the last code to

test.Controls.Add(GetButton(thisReader["session_name"].ToString(), "Join Session"));

session_id to session_name

because i want to url to have the value of the session_name

buni
  • 662
  • 2
  • 8
  • 18

2 Answers2

0
<HTML>
  <HEAD>
  <SCRIPT LANGUAGE="JavaScript">
      // include getCookie and setCookie functions here
    </SCRIPT>
  </HEAD>
  <BODY>
    <SCRIPT LANGUAGE="JavaScript">
      var username = getCookie("username");
      if (username != null) { // registered user
        document.writeln("Welcome back " + 
          username + ".");
        var visits = getCookie("visits");
        document.writeln(" You have been here " +
          visits + " time(s) before.");
        setCookie("visits",parseInt(visits)+1);
      }
      else {                  // new user
        var username = prompt("What is your name ?","");
        if (username != null) {
          setCookie("username",username);
          setCookie("visits",1);
          document.writeln("Thank you. Please reload this page.");
        }
      }
    </SCRIPT>
  </BODY>
</HTML>

Hope this will work !!!

jfriend00
  • 683,504
  • 96
  • 985
  • 979
gaurav
  • 62
  • 2
  • 7
0

Looks like you just need to get the session_name from the querystring. Check out this post here, it has a couple of nice solutions for doing that.

I see two ways of accomplishing what you want, you could add another querystring

/url.aspx?session_name=[session_name]&session_id=[session_id]

or in a session variable

session["session_id"] = session_id;
Community
  • 1
  • 1
Dave D
  • 691
  • 5
  • 11
  • yea but when i pass the session_name as querystring i have problem because the next db query is based only on seesion_id. so i have to pass the session_id as well – buni Apr 07 '12 at 12:50
  • I guess i don't understand your question. It looks like your passing the session_name variable to Page B through the querystring, and your question is how can you get that variable on the clientside? Where is seesion_id in your question? – Dave D Apr 07 '12 at 13:25
  • i update my question. in short i want to have the session_name in the url and the session_id for querying – buni Apr 07 '12 at 13:41