当前位置:编程学习 > C#/ASP.NET >>

postback 问题 望高人指教

public partial class login : System.Web.UI.UserControl
{
    protected string rurl = "default.aspx";
    protected void Page_Load(object sender, EventArgs e)
    {


      HttpCookie cookie = Request.Cookies["yzs"];
      if (Request["rUrl"] != null)
      {
          rurl = Request["rUrl"];
      }


      if (null != cookie)
      {
          string p = HttpUtility.UrlDecode(Request.Cookies["yzs"]["p"]);
          string u = HttpUtility.UrlDecode(Request.Cookies["yzs"]["username"]);
          string a = (string)Application["sqlConnectionString"];

          uservalid myvalid = new uservalid();
          string r = myvalid.user_valid(p, u, a);

          if (r == "yes")
          {
                  Panel2.Visible = true;
                  Panel1.Visible = false;
                  labusername.Text = HttpUtility.UrlDecode(Request.Cookies["yzs"]["username"]);
                  loaddata();
          }
          else
          {
              Panel1.Visible = true;
              Panel2.Visible = false;
          }
      }
      else
      {
          Panel1.Visible = true;
          Panel2.Visible = false;
      }
    }

    private void loaddata()
    {
        SqlConnection objConnection = new SqlConnection((string)Application["sqlConnectionString"]);
        objConnection.Open();
        string loadsql = "select [username],[address],[postcode],[email],[fname],[lname],[phoneno],[hpno],[password],[gender],[bod],[point],[regdate],[level],[finno] from [user] where username='" + labusername.Text + "'";

        SqlCommand loadcmd = new SqlCommand(loadsql, objConnection);
        SqlDataReader loadreader = loadcmd.ExecuteReader();
        if (loadreader.Read())
        {
            //读取会员信息
            try
            {
                labusername.Text = loadreader.GetValue(0).ToString();  
                labpoint.Text = loadreader.GetValue(11).ToString();

                loadreader.Close();
            }
            catch (SqlException ex)
            {
                // 异常处理
                Response.Write(ex.ToString());
            }
            finally
            {
                // 关闭数据库连接
                loadcmd.Connection.Close();
            }
        }
    }

每次用户登陆 panel1 就自动跳转到 panel2 所以页面无刷新 导致loaddata()无效 需要刷新页面 loaddata() 里面的信息才可以显示 那位朋友 有好的办法 解决啊 指点一下 谢谢了  --------------------编程问答-------------------- 别用 panel了
补充:.NET技术 ,  ASP.NET
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,