第四篇: UpdatePanel 控件--触发机制Triggers
之前,我们都是通过把控件放到UpdatePanel控件里的,若想要把控件放到UpdatePanel 外呢?
就可以通过Triggers 来实现.
我们通过一个例子来说明:
1.新建三个控件:ScriptManager,UpdataPanel,2个Label,DropDownList(DropDownList 控件放到UpdataPanel 外)
Label1.Text = "选择你最喜欢的宠物" (Label2 放到UpdataPanel 里)
DropDownList 启用 AutoPostBack

图8
2.接着选择UpdataPanel 属性里的Triggers
图9
然后在出现的UpdataPanelTrigger 集合编辑器里,点添加,在ControlID 里选 DropDownList1

3. 双击DropDownList1,键入以下代码:
Code
4.OK, try agan!!

图11
就可以通过Triggers 来实现.
我们通过一个例子来说明:
1.新建三个控件:ScriptManager,UpdataPanel,2个Label,DropDownList(DropDownList 控件放到UpdataPanel 外)
Label1.Text = "选择你最喜欢的宠物" (Label2 放到UpdataPanel 里)
DropDownList 启用 AutoPostBack
图8
2.接着选择UpdataPanel 属性里的Triggers
然后在出现的UpdataPanelTrigger 集合编辑器里,点添加,在ControlID 里选 DropDownList1
3. 双击DropDownList1,键入以下代码:

4.OK, try agan!!
图11
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步