这里发生了一些奇怪的事情。我目前有一个下拉drpIntervention,它具有autopostback="true“,直到现在我还在调用服务器代码,以根据所选值的不同禁用/启用控件。我不喜欢用回发来闪烁,所以我试图用UpdatePanel用AsyncPostBack触发器包装代码,但是奇怪的事情正在发生:
以下是用于此更新面板的代码:
<asp:UpdatePanel ID="UpdatePanel5" runat ="server" UpdateMode ="Conditional">
<ContentTemplate >
<tr>
<td colspan="3" class="questionFont">
<table style="width:100%; border-collapse:collapse ">
<tr>
<td>
<b>a. What is the Problem?</b>
</td>
<td >
<asp:DropDownList ID="drpCrisisType" runat="server" autopostback="true" Enabled ="false" OnSelectedIndexChanged="drpCrisisType_SelectedIndexChanged ">
</asp:DropDownList>
<span runat="server" style="font-size:12px; font-family :'Times New Roman';" ID="Span16"><i>(Description)</i></span>
</td>
</tr>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="drpIntervention" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>这是应该触发事件的按钮的代码,它位于updatePanel之外
<tr>
<td class="questionFont" style="padding-top: 20px">
<b>4. Did you engage in any?</b>
</td>
<td style="padding-top: 20px">
<asp:DropDownList ID="drpIntervention" runat="server" autopostback="true" OnSelectedIndexChanged="drpIntervention_SelectedIndexChanged ">
</asp:DropDownList>
</td>
</tr>所以这不是我的全部代码,<tr>属于一个表,它上面还有更多,这个更新面板和下拉列表只是其中的一部分。正在发生的事情是,我在浏览器中加载页面,一切看起来都很好,然后在drpIntervention中选择一个值(其他下拉列表,以及包装在更新面板中的服务器代码用于启用/禁用的文本框)被移动到页面中的其他内容之上。更奇怪的是,被移动的内容在不执行postback的情况下工作正常,但是内容也在原来的位置,在那里不起作用。
我希望我是有意义的,当我从drpIntervention中选择一个值时,update面板中的内容就在页面上的两个位置。心神不宁!
发布于 2019-04-04 18:02:26
我相信这个问题与我把asp:update panel放在哪里有关。因为我把它放在表中,它以某种方式覆盖了格式,并将更新面板中的内容带到了表的顶部。
解决这个问题的方法是,我为这个问题创建了一个表,并使用asp:update panel包装了整个表。这解决了这些问题。
https://stackoverflow.com/questions/55517278
复制相似问题