protected void Button_Click(object sender, CommandEventArgs e)
{
Response.Redirect("EnterSession.aspx?session=" + e.CommandArgument.ToString());
}
上面的代码将session_id作为查询字符串传递给EnterSession.aspx
我有以下与EnterSession.aspx
相关的c#相关代码protected string _SessionName = null;
public string SessionName;
public string sessionId
{
get
{
if (null == _SessionName)
{
SqlConnection thisConnection = new SqlConnection(@"data Source=sorce");
{
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();
thisCommand.Parameters["@SessionId"].Value = Convert.ToInt32(Request.QueryString["session"]);
using (var reader = thisCommand.ExecuteReader())
{
if (reader.Read())
{
_SessionName = reader.GetString(0);
}
else
{
throw new ArgumentException("Invalid session id");
}
}
}
}
}
return _SessionName;
}
}
现在在EnterSession.aspx中,我使用此代码将session_name传递给GA
_gaq.push(['pageTrackerTime._trackEvent', document.getElementById('session_name').value, 'test', document.location.href, roundleaveSiteEnd]);
我也在EnterSession.aspx页面中包含此代码
<input type="hidden" id="session_name" />
<script type="text/javascript">
document.getElementById('session_name').value = '<%= this.SessionName %>';
</script>
现在我找不到传递给GA服务器的session_name。
有人可以告诉我我犯了什么错误.thanx