新打开窗口,MD5加密,实体类方式保存在Session中,获得系统根路径,分页,动态获取XML数据到页面


1 分页this.lblPageIndex.Text=String.Format("第{0}页,共{1}页",this.PageIndex,pageCount);
         public void BindDG_fbInfo()
  {
    DataSet ds=new DataSet();
    B2B_HQ.DAL.fbInfo_DAL.Get_fbInfo_all(ds,"fbinfos");
    this.dg_fbInfo.DataSource=ds.Tables[0].DefaultView;
    this.dg_fbInfo.DataBind();
  }
 private void dg_fbInfo_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
  {
    //设置DataGrid当前页的索引值为用户选择的页的索引
   this.dg_fbInfo.CurrentPageIndex = e.NewPageIndex;
    //重新绑定数据
                        BindDG_fbInfo();
    //显示当前分页信息
   ShowStats();
  }
  //显示当前分页信息
  private void ShowStats()
  {
     //显示当前页面是第几页
   lblCurrentIndex.Text = "当前第是 " + (dg_fbInfo.CurrentPageIndex + 1).ToString() + " 页";
     //显示总页数
   lblPageCount.Text = "总共 " + dg_fbInfo.PageCount.ToString() + " 页";
  }
  //分别处理”最首页“、“前一页”、“下一页”和“最后页”四个按钮单击时设置DataGrid控件的当前页的索引
  public void PageButtonClick(object sender, EventArgs e)
  {
   //取得按钮单击时传递的命令参数
   string arg = ((LinkButton)sender).CommandArgument.ToString();
   switch(arg)
   {
     //如果点击的是“下一页”
    case "next":
     //如果当前页不是最后一页
     if (dg_fbInfo.CurrentPageIndex < (dg_fbInfo.PageCount - 1))
     {
      //设置DataGrid控件的当前页索引为下一页面
      dg_fbInfo.CurrentPageIndex += 1;
     }
     break;
     //如果点击的是“前一页”
    case "prev":
     //如果当前页不是首页
     if (dg_fbInfo.CurrentPageIndex > 0)
     {
      //设置DataGrid控件的当前页索引为上一页面
      dg_fbInfo.CurrentPageIndex -= 1;
     }
     break;
     //如果点击的是“最后页”
    case "last":
     //设置当前页的索引为最后一页
     dg_fbInfo.CurrentPageIndex = (dg_fbInfo.PageCount - 1);
     break;
     //默认为”最首页“
    default:
     //设置当前页的索引为首页
     dg_fbInfo.CurrentPageIndex = System.Convert.ToInt32(arg);
     break;
   }
   BindDG_fbInfo();
   ShowStats();
  }
-------------------------------------------------------------------------------------------------------------------
2 获取两表中满足条件的数据:inner join * on *
  select a.username,a,userid,b.region from emmsuser a inner join role b on a.roleid=b.roleid where a.username='cyy'
------------------------------------------------------------------------------------------------------------------
3 获得系统根路径
  string strAbs     = System.Web.HttpContext.Current.Request.Url.AbsoluteUri;  (http://localhost/CHCT/Login.aspx)
  string strRawUrl  = System.Web.HttpContext.Current.Request.RawUrl;           (/CHCT/Login.aspx)
  string strRoot    = strAbs.Substring(0,strAbs.Length - strRawUrl.Length);    (http://localhost) 获得系统根路径
------------------------------------------------------------------------------------------------------------------
4 根据用户的角色类型,而转向不同的页面
  string strrole = sessionEntity.ACCESS_REGION.ToLower();
  if(strrole == "chct" || strrole=="chec" || strrole=="hyd" || strrole=="pbda" )
   {
    sessionEntity.HOMEPAGE = "CHCT/Common_ascx/home.aspx";
   }
  else
   {
    sessionEntity.HOMEPAGE = "LOGIN.ASPX";//System.IO.Path.Combine("LOGIN.ASPX");
   }
-----------------------------------------------------------------------------------------------------------------
5 用户登录成功后,把用户所有的信息以实体类方式保存在Session中
   System.Web.HttpContext.Current.Session["sessionEntity"] = sessionEntity;
------------------------------------------------------------------------------------------------------------------
6 MD5加密
  password = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(password,"MD5");
-----------------------------------------------------------------------------------------------------------------
7 &&与,或||
  if(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count>0)
8 大写:password.ToUpper(); 小写:password.ToLower();
-----------------------------------------------------------------------------------------------------------------
9 根据返回的不同页面来转向:
  private void UserLogin()
   {
 CHCT.Entity.SessionEntity sessionEntity = Session["sessionEntity"] as CHCT.Entity.SessionEntity ;
 //登录HomePage
 Response.Redirect(sessionEntity.HOMEPAGE);
   }
------------------------------------------------------------------------------------------------------------------
10 打开窗口:
   System.Web.HttpContext.Current.Response.Write("<script>var ww = window.screen.width*0.96;var hh =window.screen.height*0.80;window.open(\"../PhotoModule/MaxMapUI.aspx\",\"\",\"height=\"+hh+\",width=\"+ww+\",top=0,left=0,scrollbars=yes,status=no,resizable=yes\")</script>");
---------------------------------------------------------------------
11分页:
  public void BindDG_fbInfo()
  {
    DataSet ds=new DataSet();
    B2B_HQ.DAL.fbInfo_DAL.Get_fbInfo_all(ds,"fbinfos");
    this.dg_fbInfo.DataSource=ds.Tables[0].DefaultView;
    this.dg_fbInfo.DataBind();
  }
 private void dg_fbInfo_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
  {
   //设置DataGrid当前页的索引值为用户选择的页的索引
   this.dg_fbInfo.CurrentPageIndex = e.NewPageIndex;
   //重新绑定数据
             BindDG_fbInfo();
   //显示当前分页信息
   ShowStats();
  }
  //显示当前分页信息
  private void ShowStats()
  {
   //显示当前页面是第几页
   lblCurrentIndex.Text = "当前第是 " + (dg_fbInfo.CurrentPageIndex + 1).ToString() + " 页";
   //显示总页数
   lblPageCount.Text = "总共 " + dg_fbInfo.PageCount.ToString() + " 页";
  }
  //分别处理”最首页“、“前一页”、“下一页”和“最后页”四个按钮单击时设置DataGrid控件的当前页的索引
  public void PageButtonClick(object sender, EventArgs e)
  {
   //取得按钮单击时传递的命令参数
   string arg = ((LinkButton)sender).CommandArgument.ToString();
   switch(arg)
   {
     //如果点击的是“下一页”
    case "next":
     //如果当前页不是最后一页
     if (dg_fbInfo.CurrentPageIndex < (dg_fbInfo.PageCount - 1))
     {
      //设置DataGrid控件的当前页索引为下一页面
      dg_fbInfo.CurrentPageIndex += 1;
     }
     break;
     //如果点击的是“前一页”
    case "prev":
     //如果当前页不是首页
     if (dg_fbInfo.CurrentPageIndex > 0)
     {
      //设置DataGrid控件的当前页索引为上一页面
      dg_fbInfo.CurrentPageIndex -= 1;
     }
     break;
     //如果点击的是“最后页”
    case "last":
     //设置当前页的索引为最后一页
     dg_fbInfo.CurrentPageIndex = (dg_fbInfo.PageCount - 1);
     break;
     //默认为”最首页“
    default:
     //设置当前页的索引为首页
     dg_fbInfo.CurrentPageIndex = System.Convert.ToInt32(arg);
     break;
   }
   BindDG_fbInfo();
   ShowStats();
  }
----------动态获取XML数据到页面.txt------------------------------------------------------------------------------------------

var xmlHttpReq = new ActiveXObject("MSXML2.XMLHTTP.3.0");
xmlHttpReq.open("GET", " http://localhost/books.xml", false);
xmlHttpReq.send();
alert(xmlHttpReq.responseText);

原文地址:https://www.cnblogs.com/csj007523/p/1260739.html