<a href="index_bblb_xx.aspx" onclick="Session['aaa'] = 'aaa';">aaaaa</a>我是想在页面上点击连接后在session["aaa"]中放个值

解决方案 »

  1.   

    up
    up
    up
    up
    up
      

  2.   

    try
    <a id="link1" href="index_bblb_xx.aspx" runat="server">aaaaa</a>page_load
    if(!Page.IsPostBack)
    {
         this.link1.Attributes.Add("onclick",Session['aaa'] = 'aaa');
    }
      

  3.   

    不知道,你具体想做什么,照本人理解,是这样些个隐藏域,把值付给隐藏域,然后在通过JS调用。
    <input id="ok" type="hidden" runat="server">.cs
    if(Session['aaa']!=null)
    {
       ok.Value = Session['aaa'].ToString();
    }
    this.link1.Attributes.Add("onclick","javascript:check()");.aspx
    function check()
    {
     strValue = ok.value;
    }
      

  4.   

    up
    up
    up
    up
    up
      

  5.   

    我的意思是
    一个链接,点一下,生成一个session
    但是因为这个连接又是动态生成的,所以不能用Attributes
      

  6.   

    呵呵,楼主不会想像模拟登陆一样进入需要验证的网页吧?呵呵,如果是这样恐怕难度有些大,呵呵。JS里面好像不能用SESSION吧,学习一下
      

  7.   

    用个隐藏的input,设为服务器端运行, js可以访问它的值,后台代码C#也能访问
      

  8.   

    你想实现功能,说清楚点
    也许没这么麻烦
    学习asp.net的资料
    http://218.27.204.17/aspnet/a_user.aspx
      

  9.   

    <a href="index_bblb_xx.aspx ? xx=aa " onclick="Session['aaa'] = 'aaa';">aaaaa</a>
    在index_bblb_xx.aspx  获得页面参数 然后处理 
    这样应该灵活点
      

  10.   

    private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
    {
    if(label_isstu.Text=="学生")
    {
    string strConnection="server=(local);database=temp;uid=sa;password=;";
    string strSQL ="exec Tstu_oncou '" + Request.Form["DropDownList1"] + "','" + label_user.Text + "'"; SqlConnection objConnection=new SqlConnection (strConnection);
    SqlCommand objCommand=new SqlCommand(strSQL,objConnection); objConnection.Open ();
    CheckBoxList1.DataSource = objCommand.ExecuteReader ();
    CheckBoxList1.DataTextField ="cou_name";
    CheckBoxList1.DataBind ();
    objConnection.Close (); }
    else 
    { ListItem li2=DropDownList2.SelectedItem;
    ListItem li3=DropDownList3.SelectedItem;
    ListItem li4=DropDownList4.SelectedItem;
    //***************************************************************
    string strConnection="server=(local);database=temp;uid=sa;password=;";
    string strSQL ="exec change_ondep '" + Request.Form["DropDownList1"] + "','" + Request.Form["DropDownList3"] + "','" + Request.Form["DropDownList4"] + "','" + str_dep + "'"; SqlConnection objConnection=new SqlConnection (strConnection);
    SqlCommand objCommand=new SqlCommand(strSQL,objConnection); objConnection.Open ();
    DropDownList2.DataSource = objCommand.ExecuteReader();
    DropDownList2.DataTextField ="dep_name";
    DropDownList2.DataBind ();
    objConnection.Close (); DropDownList2.Items.Insert(0,"全部");
    DropDownList2.SelectedIndex=DropDownList2.Items.IndexOf(li2);


    //*****************************************************************************
    //string strConnection="server=(local);database=temp;uid=sa;password=;";
    string strSQL2 ="exec change_ongrade '" + Request.Form["DropDownList1"] + "','" + Request.Form["DropDownList2"] + "','" + Request.Form["DropDownList4"] + "','" + str_grade + "'"; //SqlConnection objConnection=new SqlConnection (strConnection);
    objCommand=new SqlCommand(strSQL2,objConnection); objConnection.Open ();
    DropDownList3.DataSource = objCommand.ExecuteReader ();
    DropDownList3.DataTextField ="grade";
    DropDownList3.DataBind ();
    objConnection.Close (); DropDownList3.Items.Insert(0,"全部");
    DropDownList3.SelectedIndex=DropDownList3.Items.IndexOf(li3);
    //**************************************************************************
    string strSQL3 ="exec change_onclass '" + Request.Form["DropDownList1"] + "','" + Request.Form["DropDownList2"] + "','" + Request.Form["DropDownList3"] + "','" + str_class + "'"; objCommand=new SqlCommand(strSQL3,objConnection); objConnection.Open ();
    DropDownList4.DataSource = objCommand.ExecuteReader ();
    DropDownList4.DataTextField ="class";
    DropDownList4.DataBind ();
    objConnection.Close (); DropDownList4.Items.Insert(0,"全部");
    DropDownList4.SelectedIndex=DropDownList4.Items.IndexOf(li4);
    //******************************************************************
    string strSQL4 ="exec change_oncou '" + Request.Form["DropDownList1"] + "','" + Request.Form["DropDownList2"] + "','" + Request.Form["DropDownList3"] + "','" + Request.Form["DropDownList4"] + "','" + str_cou + "'"; objCommand=new SqlCommand(strSQL4,objConnection); objConnection.Open ();
    CheckBoxList1.DataSource = objCommand.ExecuteReader ();
    CheckBoxList1.DataTextField ="cou_name";
    CheckBoxList1.DataBind ();
    objConnection.Close ();
    } } private void DropDownList2_SelectedIndexChanged(object sender, System.EventArgs e)
    { ListItem li1=DropDownList1.SelectedItem;
    ListItem li3=DropDownList3.SelectedItem;
    ListItem li4=DropDownList4.SelectedItem;
    //****************************************************************
    string strConnection="server=(local);database=temp;uid=sa;password=;";
    string strSQL ="exec change_onscore_time '" + Request.Form["DropDownList2"] + "','" + Request.Form["DropDownList3"] + "','" + Request.Form["DropDownList4"] + "','" + str_score_time + "'";

    SqlConnection objConnection=new SqlConnection (strConnection);
    SqlCommand objCommand=new SqlCommand(strSQL,objConnection); objConnection.Open ();
    DropDownList1.DataSource = objCommand.ExecuteReader();
    DropDownList1.DataTextField ="score_time";
    DropDownList1.DataBind ();
    objConnection.Close ();

    DropDownList1.Items.Insert(0,"全部");
    DropDownList1.SelectedIndex=DropDownList1.Items.IndexOf(li1);


    //*************************************************************
    //string strConnection="server=(local);database=temp;uid=sa;password=;";
    string strSQL2 ="exec change_ongrade '" + Request.Form["DropDownList1"] + "','" + Request.Form["DropDownList2"] + "','" + Request.Form["DropDownList4"] +"','" + str_grade + "'";

    //SqlConnection objConnection=new SqlConnection (strConnection);
    objCommand=new SqlCommand(strSQL2,objConnection); objConnection.Open ();
    DropDownList3.DataSource = objCommand.ExecuteReader();
    DropDownList3.DataTextField ="grade";
    DropDownList3.DataBind ();
    objConnection.Close (); DropDownList3.Items.Insert(0,"全部");
    DropDownList3.SelectedIndex=DropDownList3.Items.IndexOf(li3);
    //************************************************************************
    string strSQL3 ="exec change_onclass '" + Request.Form["DropDownList1"] + "','" + Request.Form["DropDownList2"] + "','" + Request.Form["DropDownList3"] + "','" + str_class + "'";

    objCommand=new SqlCommand(strSQL3,objConnection); objConnection.Open ();
    DropDownList4.DataSource = objCommand.ExecuteReader();
    DropDownList4.DataTextField ="class";
    DropDownList4.DataBind ();
    objConnection.Close (); DropDownList4.Items.Insert(0,"全部");
    DropDownList4.SelectedIndex=DropDownList4.Items.IndexOf(li4);
    //******************************************************************
    string strSQL4 ="exec change_oncou '" + Request.Form["DropDownList1"] + "','" + Request.Form["DropDownList2"] + "','" + Request.Form["DropDownList3"] + "','" + Request.Form["DropDownList4"] + "','" + str_cou + "'"; objCommand=new SqlCommand(strSQL4,objConnection); objConnection.Open ();
    CheckBoxList1.DataSource = objCommand.ExecuteReader ();
    CheckBoxList1.DataTextField ="cou_name";
    CheckBoxList1.DataBind ();
    objConnection.Close ();

    } private void DropDownList3_SelectedIndexChanged(object sender, System.EventArgs e)
    {            ListItem li1=DropDownList1.SelectedItem;
    ListItem li2=DropDownList2.SelectedItem;
    ListItem li4=DropDownList4.SelectedItem;
      

  11.   

    //*****************************************************************
    string strConnection="server=(local);database=temp;uid=sa;password=;";
    string strSQL ="exec change_onscore_time '" + Request.Form["DropDownList2"] + "','" + Request.Form["DropDownList3"] + "','" + Request.Form["DropDownList4"] + "','" + str_score_time + "'";

    SqlConnection objConnection=new SqlConnection (strConnection);
    SqlCommand objCommand=new SqlCommand(strSQL,objConnection); objConnection.Open ();
    DropDownList1.DataSource = objCommand.ExecuteReader();
    DropDownList1.DataTextField ="score_time";
    DropDownList1.DataBind ();
    objConnection.Close ();
    DropDownList1.Items.Insert(0,"全部");
    DropDownList1.SelectedIndex=DropDownList1.Items.IndexOf(li1);
    //****************************************************************
    //string strConnection="server=(local);database=temp;uid=sa;password=;";
    string strSQL2 ="exec change_ondep '" + Request.Form["DropDownList1"] + "','" + Request.Form["DropDownList3"] + "','" + Request.Form["DropDownList4"] + "','" + str_dep + "'"; //SqlConnection objConnection=new SqlConnection (strConnection);
    objCommand=new SqlCommand(strSQL2,objConnection); objConnection.Open ();
    DropDownList2.DataSource = objCommand.ExecuteReader();
    DropDownList2.DataTextField ="dep_name";
    DropDownList2.DataBind ();
    objConnection.Close (); DropDownList2.Items.Insert(0,"全部");
    DropDownList2.SelectedIndex=DropDownList2.Items.IndexOf(li2);
    //******************************************************************
    string strSQL3 ="exec change_onclass '" + Request.Form["DropDownList1"] + "','" + Request.Form["DropDownList2"] + "','" + Request.Form["DropDownList3"] + "','" + str_class + "'"; objCommand=new SqlCommand(strSQL3,objConnection); objConnection.Open ();
    DropDownList4.DataSource = objCommand.ExecuteReader();
    DropDownList4.DataTextField ="class";
    DropDownList4.DataBind ();
    objConnection.Close (); DropDownList4.Items.Insert(0,"全部");
    DropDownList4.SelectedIndex=DropDownList4.Items.IndexOf(li4);
    //************************************************************
    string strSQL4 ="exec change_oncou '" + Request.Form["DropDownList1"] + "','" + Request.Form["DropDownList2"] + "','" + Request.Form["DropDownList3"] + "','" + Request.Form["DropDownList4"] + "','" + str_cou + "'"; objCommand=new SqlCommand(strSQL4,objConnection); objConnection.Open ();
    CheckBoxList1.DataSource = objCommand.ExecuteReader ();
    CheckBoxList1.DataTextField ="cou_name";
    CheckBoxList1.DataBind ();
    objConnection.Close ();

    } private void DropDownList4_SelectedIndexChanged(object sender, System.EventArgs e)
    { ListItem li1=DropDownList1.SelectedItem;
    ListItem li2=DropDownList2.SelectedItem;
    ListItem li3=DropDownList3.SelectedItem;
    //*****************************************************************
    string strConnection="server=(local);database=temp;uid=sa;password=;";
    string strSQL ="exec change_onscore_time '" + Request.Form["DropDownList2"] + "','" + Request.Form["DropDownList3"] + "','" + Request.Form["DropDownList4"] + "','" + str_score_time + "'";

    SqlConnection objConnection=new SqlConnection (strConnection);
    SqlCommand objCommand=new SqlCommand(strSQL,objConnection); objConnection.Open ();
    DropDownList1.DataSource = objCommand.ExecuteReader();
    DropDownList1.DataTextField ="score_time";
    DropDownList1.DataBind ();
    objConnection.Close ();

    DropDownList1.Items.Insert(0,"全部");
    DropDownList1.SelectedIndex=DropDownList1.Items.IndexOf(li1);
    //**********************************************************
    //string strConnection="server=(local);database=temp;uid=sa;password=;";
    string strSQL2 ="exec change_ondep '" + Request.Form["DropDownList1"] + "','" + Request.Form["DropDownList3"] + "','" + Request.Form["DropDownList4"] + "','" + str_dep + "'"; //SqlConnection objConnection=new SqlConnection (strConnection);
    objCommand=new SqlCommand(strSQL2,objConnection); objConnection.Open ();
    DropDownList2.DataSource = objCommand.ExecuteReader();
    DropDownList2.DataTextField ="dep_name";
    DropDownList2.DataBind ();
    objConnection.Close (); DropDownList2.Items.Insert(0,"全部");
    DropDownList2.SelectedIndex=DropDownList2.Items.IndexOf(li2);
    //******************************************************************
    string strSQL3 ="exec change_ongrade '" + Request.Form["DropDownList1"] + "','" + Request.Form["DropDownList2"] + "','" + Request.Form["DropDownList4"] +"','" + str_grade + "'";

    objCommand=new SqlCommand(strSQL3,objConnection); objConnection.Open ();
    DropDownList3.DataSource = objCommand.ExecuteReader();
    DropDownList3.DataTextField ="grade";
    DropDownList3.DataBind ();
    objConnection.Close (); DropDownList3.Items.Insert(0,"全部");
    DropDownList3.SelectedIndex=DropDownList3.Items.IndexOf(li3);
      

  12.   

    //*****************************************************************
    string strSQL4 ="exec change_oncou '" + Request.Form["DropDownList1"] + "','" + Request.Form["DropDownList2"] + "','" + Request.Form["DropDownList3"] + "','" + Request.Form["DropDownList4"] + "','" + str_cou + "'"; objCommand=new SqlCommand(strSQL4,objConnection); objConnection.Open ();
    CheckBoxList1.DataSource = objCommand.ExecuteReader ();
    CheckBoxList1.DataTextField ="cou_name";
    CheckBoxList1.DataBind ();
    objConnection.Close ();

    } private void Button2_Click(object sender, System.EventArgs e)
    {
    if(true)
    {
    string strConnection="server=(local);database=temp;uid=sa;password=;";
    string strSQL ="exec load_score_time '" + label_user.Text + "','" + label_isstu.Text + "'";
    SqlConnection objConnection=new SqlConnection (strConnection);
    SqlCommand objCommand=new SqlCommand(strSQL,objConnection); objConnection.Open ();
    DropDownList1.DataSource = objCommand.ExecuteReader ();
    DropDownList1.DataTextField ="score_time";
    DropDownList1.DataBind ();
    objConnection.Close (); DropDownList1.Items.Insert(0,"全部");
    DropDownList1.Items[0].Selected=true; } if(true)
    {
    if(label_isstu.Text=="学生")
    {
    //do nothing

    }
    else
    {
    string strConnection="server=(local);database=temp;uid=sa;password=;";
    string strSQL ="exec load_dep '" + label_user.Text + "','" + label_isstu.Text + "'";
    SqlConnection objConnection=new SqlConnection (strConnection);
    SqlCommand objCommand=new SqlCommand(strSQL,objConnection); objConnection.Open ();
    DropDownList2.DataSource = objCommand.ExecuteReader ();
    DropDownList2.DataTextField ="dep_name";
    DropDownList2.DataBind ();
    objConnection.Close ();

    DropDownList2.Items.Insert(0,"全部");
    DropDownList2.Items[0].Selected=true; }
    } if(true)
    {
    if(label_isstu.Text=="学生")
    {
    //do nothing

    }
    else
    {
    string strConnection="server=(local);database=temp;uid=sa;password=;";
    string strSQL ="exec load_grade '" + label_user.Text + "','" + label_isstu.Text + "'";
    SqlConnection objConnection=new SqlConnection (strConnection);
    SqlCommand objCommand=new SqlCommand(strSQL,objConnection); objConnection.Open ();
    DropDownList3.DataSource = objCommand.ExecuteReader ();
    DropDownList3.DataTextField ="grade";
    DropDownList3.DataBind ();
    objConnection.Close ();

    DropDownList3.Items.Insert(0,"全部");
    DropDownList3.Items[0].Selected=true; }
    } if(true)
    {
    if(label_isstu.Text=="学生")
    {
    //do nothing

    }
    else
    {
    string strConnection="server=(local);database=temp;uid=sa;password=;";
    string strSQL ="exec load_class '" + label_user.Text + "','" + label_isstu.Text + "'";
    SqlConnection objConnection=new SqlConnection (strConnection);
    SqlCommand objCommand=new SqlCommand(strSQL,objConnection); objConnection.Open ();
    DropDownList4.DataSource = objCommand.ExecuteReader ();
    DropDownList4.DataTextField ="class";
    DropDownList4.DataBind ();
    objConnection.Close ();

    DropDownList4.Items.Insert(0,"全部");
    DropDownList4.Items[0].Selected=true; }
    } if(true)
    {
    string strConnection="server=(local);database=temp;uid=sa;password=;";
    string strSQL ="exec load_cou '" + label_user.Text + "','" + label_isstu.Text + "'";
    SqlConnection objConnection=new SqlConnection (strConnection);
    SqlCommand objCommand=new SqlCommand(strSQL,objConnection); objConnection.Open ();
    CheckBoxList1.DataSource = objCommand.ExecuteReader ();
    CheckBoxList1.DataTextField ="cou_name";
    CheckBoxList1.DataBind ();
    objConnection.Close ();

    } if(true)
    {
    if(label_isstu.Text=="学生")
    {
    //do nothing

    }
    else
    {
    TextBox1.Text=""; }
    } } private void CheckBoxList1_SelectedIndexChanged(object sender, System.EventArgs e)
    {
    //do nothing

    } private void Button3_Click(object sender, System.EventArgs e)
    {
    //全选
    for(int i=0;i < CheckBoxList1.Items.Count;i++)
    {
    CheckBoxList1.Items[i].Selected=true; } } private void Button4_Click(object sender, System.EventArgs e)
    {
    //全不选
    for(int i=0;i < CheckBoxList1.Items.Count;i++)
    {
    CheckBoxList1.Items[i].Selected=false; }

    }
    }
    }