editimage.aspx.cs

来自「三层架构的.net源码三层架构的.net源码」· CS 代码 · 共 108 行

CS
108
字号
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace MyStarterKit.Portal.Web
{
	/// <summary>
	/// EditImage 的摘要说明。
	/// </summary>
	public class EditImage : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.TextBox Src;
		protected System.Web.UI.WebControls.TextBox Width;
		protected System.Web.UI.WebControls.TextBox Height;
		protected System.Web.UI.WebControls.LinkButton updateButton;
		protected System.Web.UI.WebControls.LinkButton cancelButton;

		int moduleId = 0;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			// 所属模块Id
			moduleId = Int32.Parse(Request.Params["Mid"]);

			// 验证用户是否可以修改指定模块
			if (PortalSecurity.HasEditPermissions(moduleId) == false) 
			{
				Response.Redirect("~/Admin/EditAccessDenied.aspx");
			}

			if (!Page.IsPostBack) 
			{
				if (moduleId > 0) 
				{
					Hashtable settings;
					// 获取该模块设置信息
					settings = Configuration.GetModuleSettings(moduleId);
                
					Src.Text = (String) settings["src"];
					Width.Text = (String) settings["width"];
					Height.Text = (String) settings["height"];
				}
            
				// 存储上一请求页用于返回
				ViewState["UrlReferrer"] = Request.UrlReferrer.ToString();
			}
		}

		/// <summary>
		/// 更新保存设置
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void UpdateBtn_Click(Object sender, EventArgs e) 
		{
			Configuration config = new Configuration();
        
			config.UpdateModuleSetting(moduleId, "src", Src.Text);
			config.UpdateModuleSetting(moduleId, "height", Height.Text);
			config.UpdateModuleSetting(moduleId, "width", Width.Text);

			// 返回
			Response.Redirect((String) ViewState["UrlReferrer"]);
		}

		/// <summary>
		/// 取消
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void CancelBtn_Click(Object sender, EventArgs e) 
		{
			// 返回
			Response.Redirect((String) ViewState["UrlReferrer"]);
		}


		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.updateButton.Click += new System.EventHandler(this.UpdateBtn_Click);
			this.cancelButton.Click += new System.EventHandler(this.CancelBtn_Click);
			this.Load += new System.EventHandler(this.Page_Load);
		}
		#endregion
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?