简体   繁体   English

如何在更新面板内调用/触发 javascript 函数<trigger>标签

[英]How to call/trigger javascript function inside the update panel <trigger> tag

I have an dropdown list box.我有一个下拉列表框。 I am loading the values from server to that list box, and the values are loading correctly.我正在将值从服务器加载到该列表框,并且值加载正确。

I am using an <trigger> event to trigger the C# function to display the elements.我正在使用<trigger>事件来触发 C# 函数以显示元素。

Now I want to do this in javascript.现在我想在 javascript 中做到这一点。 How to I do that.我该怎么做。

My control is located inside the updatepanel .我的控件位于updatepanel My code is:我的代码是:

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
       <asp:DropDownList ID="list1" runat="server" Height="20px" Width="250px"
           OnSelectedIndexChanged="list1_SelectedIndexChanged" >
             <asp:ListItem>--Select--</asp:ListItem>
        </asp:DropDownList>
    </ContentTemplate>
    <Triggers>
       <asp:AsyncPostBackTrigger ControlID="list1" Name="SelectedIndexChanged"/>
    <Triggers>
</asp:UpdatePanel>

Now I want to call the Javascript function inside that trigger event.现在我想在该触发事件中调用 Javascript 函数。 How do I do it, and is it even possible to do?我该怎么做,甚至有可能做到吗?

If you want to call a function on the change event of the drop down then you can use the change() event of jquery.如果要在下拉列表的更改事件上调用函数,则可以使用 jquery 的 change() 事件。 Also while calling javascript functions there is no need to use the update pannel.此外,在调用 javascript 函数时,无需使用更新面板。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM