您的位置:首页 > 其它

扩展 TextBox 控件 - 依 FormViewMode 来自行设定状态

2008-05-14 22:58 337 查看
摘要

延续前面「GridView+FormView 示范数据新增/修改/删除(进阶篇:服务器控件)」的文章,文章后记有提及若要达到零程序代码要求,上篇已实作「扩展 CommandField 类别 - Header 加入新增钮」解决其中一个问题。另一个问题就要扩展 TextBox 控件,让 TextBox 可以自行判断 FormView 的 CurrentMode 来决定 TextBox 的启用状态,本文接下来就是来说明如何扩展 TextBox 控件来达到此需求。

TBFormViewModeStatus 类别

首先我们先定义 TBFormViewModeStatus 类别,此类别是用来设定控件在每种 FormViewMode 的状态。TBFormViewModeStatus 类别具有 InsertMode、EditMode、BrowseMode 三个属性,分别用来设定 FormViewMode 为 Insert、Edit、ReadOnly 三种情形时,TextBox 控件的启用状态。

1

19 < _

23 Serializable(), _

24 TypeConverter(GetType(ExpandableObjectConverter)) _

25 > _

26Imports System

2Imports System.ComponentModel

3Imports System.Drawing

4Imports System.Web

5Imports System.Web.UI

6Imports System.Web.UI.WebControls

7Imports System.Security.Permissions

8

9<bee:TBTextBox ID="txtEmployeeID" runat="server" Text='<%# Bind("EmployeeID") %>'>

<FormViewModeStatus InsertMode="Enable" EditMode="Disable" />

</bee:TBTextBox>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: