Passing values between asp.net pages
<p>I  have this code in EnterSession.aspx.cs</p>

<pre><code>[System.Web.Services.WebMethod]
            public static string GetSessionName(string session_name, int SessionId)
            {
                string result = "";
                try
                {
                    SqlConnection thisConnection = new SqlConnection(@"data Source=ZOLA-PC;AttachDbFilename=D:\2\5.Devp\ASPNETDB.MDF;Integrated Security=True");
                    thisConnection.Open();
                    SqlCommand thisCommand = thisConnection.CreateCommand();
                    thisCommand.CommandText = " SELECT session_name FROM myApp_Session WHERE session_id = @SessionId;";
                    thisCommand.Parameters.AddWithValue("SessionId", SessionId);
                    SqlDataReader thisReader = thisCommand.ExecuteReader();
                    while (thisReader.Read())
                    {
                        result = thisReader["session_name"].ToString();
                    }
                    thisReader.Close();
                    thisConnection.Close();
                    return result;
                }
                catch (SqlException ex)
                {
                    return ex.Message;
                }
            }
</code></pre>

<p>then I used these codes in EnterSession.aspx page</p>

<pre><code>gaq.push(['pageTrackerTime._trackEvent', 'Fancy Running Session', document.getElementById('session_name').value, document.location.href, roundleaveSiteEnd]);
</code></pre>

<p>and the other part of the code is </p>

<pre><code> &lt;input type="hidden" id="session_name" /&gt;
&lt;script type="text/javascript"&gt;
    document.getElementById('session_name').value = '&lt;%= this.SessionName %&gt;';
&lt;/script&gt;
</code></pre>

<p>The idea behind is to fetch the session_name from the db based on the session_id passed from previous page and pass it to Google analytic server using get element by id.</p>

<p>this implementation didn't work for me, where could be my mistake? thanx in advance </p>
