控制事件不是从内部的UpdatePanel射击 [英] Control event not firing from within updatepanel
问题描述
我有一个正在通过一个定时器更新,如预期的UpdatePanel内工作。一个列表框
不过,我不能让SelectedIndexChanged事件射击。我presume这是值得做的部分回发。有谁知道我能做些什么,使这项工作?
当我将它移出的UpdatePanel的正常工作。但是很明显,我不能做部分回发。
< ASP:的UpdatePanel ID =的UpdatePanel=服务器的UpdateMode =条件>
<&的ContentTemplate GT;
< ASP:定时器ID =定时器=服务器OnTick =Timer1_Tick间隔=500>< / ASP:定时器>
< ASP:列表框ID =ListBox_JobPositionsOnSelectedIndexChanged =ListBox_JobPositions_SelectedIndexChanged=服务器HEIGHT =750pxWIDTH =300像素的DataSourceID =SqlDataSource的DataTextField =公司DataValueField =PID>< / ASP:列表框>
< /&的ContentTemplate GT;
< / ASP:的UpdatePanel>
更新:
现在试过下面的变化,计时器事件仍在工作,但SelectedIndexChanged事件是没有的。我迷路与此有关。
< ASP:的UpdatePanel ID =的UpdatePanel=服务器ChildrenAsTriggers =FALSE的UpdateMode =条件>
<&的ContentTemplate GT;
< ASP:定时器ID =定时器=服务器OnTick =Timer1_Tick间隔=500>< / ASP:定时器>
< ASP:列表框ID =ListBox_JobPositions=服务器HEIGHT =750pxWIDTH =300像素的DataSourceID =SqlDataSource的DataTextField =公司DataValueField =PIDOnSelectedIndexChanged =ListBox_JobPositions_SelectedIndexChanged的AutoPostBack =真 >< / ASP:列表框>
< /&的ContentTemplate GT;
<&触发器GT;
< ASP:AsyncPostBackTrigger控件ID =定时器/>
< /触发器>
下面是当列表框是UpdatePanel内,但确实工作的时候它不是不火的事件。
保护无效ListBox_JobPositions_SelectedIndexChanged(对象发件人,EventArgs的发送)
{
的Response.Write(测试);
}
现在的工作,必须手工指定异步和完全回发触发器。感谢您的帮助。
< ASP:的UpdatePanel ID =的UpdatePanel=服务器ChildrenAsTriggers =FALSE的UpdateMode =条件>
<&的ContentTemplate GT;
< ASP:定时器ID =定时器=服务器OnTick =Timer1_Tick间隔=500>< / ASP:定时器>
< ASP:列表框ID =ListBox_JobPositions=服务器HEIGHT =750pxWIDTH =300像素的DataSourceID =SqlDataSource的DataTextField =公司DataValueField =PIDOnSelectedIndexChanged =ListBox_JobPositions_SelectedIndexChanged的AutoPostBack =真 >< / ASP:列表框>
< /&的ContentTemplate GT;
<&触发器GT;
< ASP:AsyncPostBackTrigger控件ID =定时器/>
< ASP:PostBackTrigger控件ID =ListBox_JobPositions/>
< /触发器>
< / ASP:的UpdatePanel>
I have a listbox that is being updated via a timer and working as expected inside an UpdatePanel.
However I cannot get the selectedindexchanged event to fire. I presume this is something to do with the partial postback. Does anybody know what I can do to make this work?
When I move it out of the UpdatePanel it works fine. However obviously I cannot do partial postbacks.
<asp:UpdatePanel ID="UpdatePanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Timer ID="Timer1" runat="server" OnTick="Timer1_Tick" Interval="500"></asp:Timer>
<asp:ListBox ID="ListBox_JobPositions" OnSelectedIndexChanged="ListBox_JobPositions_SelectedIndexChanged" runat="server" Height="750px" Width="300px" DataSourceID="sqlDataSource" DataTextField="Company" DataValueField="Pid"></asp:ListBox>
</ContentTemplate>
</asp:UpdatePanel>
UPDATE:
Have now tried the below change, the timer event is still working but the selectedindexchanged event is not. I am getting lost with this.
<asp:UpdatePanel ID="UpdatePanel" runat="server" ChildrenAsTriggers="False" UpdateMode="Conditional">
<ContentTemplate>
<asp:Timer ID="Timer1" runat="server" OnTick="Timer1_Tick" Interval="500"></asp:Timer>
<asp:ListBox ID="ListBox_JobPositions" runat="server" Height="750px" Width="300px" DataSourceID="sqlDataSource" DataTextField="Company" DataValueField="Pid" OnSelectedIndexChanged="ListBox_JobPositions_SelectedIndexChanged" AutoPostBack="True"></asp:ListBox>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" />
</Triggers>
Here is the event that does not fire when the listbox is inside the UpdatePanel but does work when it is not.
protected void ListBox_JobPositions_SelectedIndexChanged(object sender, EventArgs e)
{
Response.Write("test");
}
Works now, had to manually specify Async and Full Postback triggers. Thanks for your help.
<asp:UpdatePanel ID="UpdatePanel" runat="server" ChildrenAsTriggers="False" UpdateMode="Conditional">
<ContentTemplate>
<asp:Timer ID="Timer1" runat="server" OnTick="Timer1_Tick" Interval="500"></asp:Timer>
<asp:ListBox ID="ListBox_JobPositions" runat="server" Height="750px" Width="300px" DataSourceID="sqlDataSource" DataTextField="Company" DataValueField="Pid" OnSelectedIndexChanged="ListBox_JobPositions_SelectedIndexChanged" AutoPostBack="True"></asp:ListBox>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" />
<asp:PostBackTrigger ControlID="ListBox_JobPositions" />
</Triggers>
</asp:UpdatePanel>
这篇关于控制事件不是从内部的UpdatePanel射击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!