切换城市功能

与切换城市类似,实例为切换不同的数据库源。

主要功能:

  1. 记录请求页面

  2. 切换数据库源

  3. 返回到请求页面

 1 public partial class SelectDB : BasePage
 2 {
 3     ......
 4     public string SrcUrl 
 5     {
 6         get { return Session["srcurl"] == null || Session["srcurl"].ToString().Equals("/SignOn.aspx") ? "QueryPlanByMonth.aspx" : Session["srcurl"].ToString(); }
 7         private set { Session["srcurl"] = value; } 
 8     }
 9     protected void Page_Load(object sender, EventArgs e)
10     {
11         if (!IsPostBack)
12         {
13             if (Request.UrlReferrer != null)
14             {
15                 SrcUrl = Request.UrlReferrer.AbsolutePath;
16             }
17         }
18     }
19     protected void LbtnFQ_Click(object sender, EventArgs e)
20     {
21         SetConnAndRedirect("AAConn");
22     }
23     protected void LbtnFG_Click(object sender, EventArgs e)
24     {
25         SetConnAndRedirect("BBGConn");
26     }
27 
28     private void SetConnAndRedirect(string conn)
29     {
30         base.DBConn = conn;
31         Response.Redirect(SrcUrl);
32     }
33 }
34 public class BasePage : Page
35 {
36     ......
37     protected string DBConn {
38         private get
39         {
40             return Session["DBConn"] == null ?
41                     "LFConn" :
42                     Session["DBConn"].ToString();
43             }
44         set { Session["DBConn"] = value; } 
45     }
46     ......
47 }

 

转载于:https://www.cnblogs.com/zhuhc/p/3455094.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值