禁用或啟用DropDownList的Items

2022-02-14 00:46:32 字數 1198 閱讀 1587

此篇算是對重構公升級。

因為網友需要不但能禁用還能可以啟用dropdownlist的items。為了不想使用者寫太多**。insus.net寫了乙個類別,並讓它繼承了system.web.ui.webcontrols命名空間下的dropdownlist. 可從下圖看到insusdropdownlist例項化並傳入dropdownlist控制項,然後例項化之後的物件,就是可以使用highlight的四個方法disableimsbytext(), disabletemsbyvue() ,enableitemsbtext(), enableitemsbyvalue()。

insusdropdownlist類別:

insusdropdownlist

using system;

using system.collections.generic;

using system.linq;

using system.web;

using system.web.ui.webcontrols;

//////

summary description for insusdropdownlist

///namespace insus.net

public

void disableitemsbytext(string text)

public

void enableitemsbytext(string text)

public

void disableitemsbyvalue(string value)

public

void enableitemsbyvalue(string value)

private

int getindexbytext(string text)

private

int getindexbyvalue(string value)

private

void disableitems(int index)

private

void enableitems(int index)}}

演示,啟用items: 

if (request.querystring["

site

"] != null)

在Word 2007中啟用或禁用Office載入項

office載入項是office程式為了完成某種功能而需要在啟動程式時自動載入的模組,例如書法字帖功能 稿紙功能 製作信封功能等。使用者可以根據工作需要啟用或禁用office載入項,以提高office程式的執行效率。在word2007中啟用或禁用office載入項的步驟如下所述 第1步,開啟word...

CentOS 7啟用或禁用啟動項

面試 你懂什麼是分布式系統嗎?redis分布式鎖都不會?在rhel centos 7上,通過使用systemctl命令檢查,可以執行systemctl status命令檢查服務的執行狀態 最後乙個單詞enabled或者disabled會告訴我們服務的狀態,在以上的示例中,apache2 web伺服器...

網絡卡禁用和啟用

2010 11 10 21 34 23 include include include setupapi.h include objbase.h include pragma comment lib,setupapi.lib void enumdevices hdevinfo hdevinfo lp...