【发布时间】:2012-01-13 04:39:05
【问题描述】:
看看这个标记:
<asp:UpdatePanel ID="Panel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:DropDownList ID="cboBox1" ClientIDMode="Static" AutoPostBack="true" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:DropDownList ID="cboBox2" runat="server" />
<asp:UpdateProgress ID="UpdateProgress1" style="display: inline" AssociatedUpdatePanelID="Panel1" DynamicLayout="false" DisplayAfter="0" runat="server">
<ProgressTemplate>
<img src='<%= ResolveClientUrl("~/Images/indicator.gif")%>' border="0" alt="" />
</ProgressTemplate>
</asp:UpdateProgress>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="cboBox1" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
UpdateProgress 控件最初可以工作,但是当我们将 ClientMode="Static" 添加到 cboBox1 时就坏了。将其恢复为 AutoID 不是一种选择,因此我需要找到允许 UpdateProgress 面板与 ClientIDMode="Static" 一起使用的解决方案。
另外,有人可以在标签列表中添加“clientidmode”吗?
【问题讨论】:
-
请问为什么一定要使用静态客户端模式?您是否在某些 javascript 中使用该控件?
-
为什么不能选择“AutoID”模式?
-
是的,我们在Javascript中使用它,但是Javascript是从另一个文件导入的,所以我们不能使用服务器标签。我们可以将各种 Javascript 函数移到主页上,但这是我们不想在游戏后期这样做的事情。我们从一个离岸开发团队继承了这个写得很糟糕的应用程序,它不能很好地发挥最佳实践,所以我们现在正在尽我们所能,直到需要从头开始重写它。不仅如此,您只需要相信我。
-
你在你的项目中使用jquery吗(这只是一个问题,我不是告诉你应该使用它...)?如果是这样,您可以使用属性选择器选择使用 ClientIDMode="AutoID" 创建的元素:
$('select[id$=cboBox2]')(id 以 "cboBox2" 结尾) -
我们使用jquery。如果我确实得到了对 cboBox2 的引用,我最终会用它做什么?
标签: javascript asp.net static updatepanel updateprogress