在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
近时间的开发专案中,再次对ASP.NET的编辑界面进行简化。从这里可以看到以前的两个版本简化:ASP.NET简化编辑界面 和 ASP.NET简化编辑界面 V2 首先看看本次效果,本效果是在Microsoft Visual Studio 11 Beta 和 Microsoft SQL Server 2012 环境之下实现:
编辑工具条写成为一个用户控件(UserControl):
View Code
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Operation.ascx.cs" Inherits="SubscriptionControl_Operation" %>
<div style="position: absolute; top: 84.5px; left: 3px;"> <asp:Button ID="ButtonCreate" runat="server" Text="新建" OnClick="ButtonCreate_Click" /> <asp:Button ID="ButtonEdit" runat="server" Text="编辑" OnClick="ButtonEdit_Click" Enabled="false" /> <asp:Button ID="ButtonDelete" runat="server" Text="删除" OnClick="ButtonDelete_Click" Enabled="false" /> <asp:Button ID="ButtonCancel" runat="server" Text="取消" OnClick="ButtonCancel_Click" Enabled="false" /> <asp:Button ID="ButtonSave" runat="server" Text="保存" OnClick="ButtonSave_Click" Enabled="false" /> </div>
Operation.ascx.cs:
View Code
using System;
using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Insus.NET; public partial class SubscriptionControl_Operation : System.Web.UI.UserControl { public delegate void EventHandler(object sender, EventArgs e); public event EventHandler InsusCreate; public event EventHandler InsusCancel; public event EventHandler InsusEdit; public event EventHandler InsusDelete; public event EventHandler InsusSave; public Button CreateButton { get { return this.ButtonCreate; } } public Button EditButton { get { return this.ButtonEdit; } } public Button CancelButton { get { return this.ButtonCancel; } } public Button DeleteButton { get { return this.ButtonDelete; } } public Button SaveButton { get { return this.ButtonSave; } } protected void Page_Load(object sender, EventArgs e) { } protected void ButtonCreate_Click(object sender, EventArgs e) { if (InsusCreate != null) { this.ButtonEdit.Enabled = false; this.ButtonDelete.Enabled = false; this.ButtonCancel.Enabled = true; this.ButtonSave.Enabled = true; InsusCreate(this, e); } } protected void ButtonEdit_Click(object sender, EventArgs e) { if (InsusEdit != null) InsusEdit(this, e); } protected void ButtonCancel_Click(object sender, EventArgs e) { if (InsusCancel != null) { this.ButtonEdit.Enabled = false; this.ButtonCancel.Enabled = false; this.ButtonDelete.Enabled = false; this.ButtonSave.Enabled = false; InsusCancel(this, e); } } protected void ButtonDelete_Click(object sender, EventArgs e) { if (InsusDelete != null) InsusDelete(this, e); } protected void ButtonSave_Click(object sender, EventArgs e) { if (InsusSave != null) { this.ButtonEdit.Enabled = false; this.ButtonDelete.Enabled = false; this.ButtonCancel.Enabled = false; this.ButtonSave.Enabled = false; InsusSave(this, e); } } }
页面实现的代码,由于没有使用到Javascript和JQuery,全是asp.net实现。因此代码就在此略了。 如果以后有时间或是把.NET实现的代码改为Javascript或是JQuery,一定会帖出来分享给大家。
|
请发表评论