Web系統中經常會遇到這樣的情況
比較簡單的解決方法就是在用戶進行了點擊操作將按鈕之類的東西隱藏掉
下面是頁面代碼的一個示例
<%@ Register Assembly=
<!DOCTYPE html PUBLIC
<html xmlns=
<head runat=
<title>Untitled Page</title>
</head>
<body>
<form id=
<div>
<King:LoadingControl runat=
<ContentTemplate>
<asp:Button ID=
</ContentTemplate>
<ProgressTemplate>
<img src=
</ProgressTemplate>
</King:LoadingControl>
</div>
</form>
</body>
</html>
為了能看到Loading的效果我們在Page_Load中使用System
頁面render出來的代碼如下
<html xmlns=
<head><title>
Untitled Page
</title></head>
<body>
<form name=
<div>
<input type=
</div>
<div>
<span><span onclick=
<input type=
</span><span id=
<img src=
</span></span>
</div>
<div>
<input type=
</div></form>
</body>
</html>
控件實現
其實就兩個要點
控件要支持兩個模板一個是ContentTemplate這個是要隱藏部分的模板
using System;
using System
using System
using System
using System
using System
using System
namespace KingWebControlToolkit
{
[
AspNetHostingPermission(SecurityAction
Level = AspNetHostingPermissionLevel
AspNetHostingPermission(SecurityAction
Level = AspNetHostingPermissionLevel
ToolboxData(
]
public class LoadingControl : CompositeControl
{
private ITemplate contentTempalte;
private ITemplate progressTemplate;
private TemplateContainer contentContainer;
private TemplateContainer progressContainer;
[
Browsable(false)
DesignerSerializationVisibility(
DesignerSerializationVisibility
]
public TemplateContainer Owner
{
get
{
return contentContainer;
}
}
[
Browsable(false)
PersistenceMode(PersistenceMode
DefaultValue(typeof(ITemplate)
Description(
TemplateContainer(typeof(LoadingControl ))
]
public virtual ITemplate ContentTemplate
{
get
{
return contentTempalte;
}
set
{
contentTempalte = value;
}
}
[
Browsable(false)
PersistenceMode(PersistenceMode
DefaultValue(typeof(ITemplate)
Description(
TemplateContainer(typeof(LoadingControl))
]
public virtual ITemplate ProgressTemplate
{
get
{
return progressTemplate;
}
set
{
progressTemplate = value;
}
}
protected override void CreateChildControls()
{
Controls
contentContainer = new TemplateContainer();
progressContainer = new TemplateContainer();
contentContainer
contentContainer
progressContainer
progressContainer
ITemplate temp = contentTempalte;
if (temp == null)
{
temp = new DefaultTemplate();
}
temp
temp = progressTemplate;
temp
this
this
}
}
[
ToolboxItem(false)
]
public class TemplateContainer : WebControl
{
}
DefaultTemplate
}
From:http://tw.wingwit.com/Article/program/net/201311/13979.html