Ramesh
Ramesh

Reputation: 1083

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.

Now I want to do this in javascript. How to I do that.

My control is located inside the 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. How do I do it, and is it even possible to do?

Upvotes: 1

Views: 1325

Answers (1)

Anshuman Jasrotia
Anshuman Jasrotia

Reputation: 3175

If you want to call a function on the change event of the drop down then you can use the change() event of jquery. Also while calling javascript functions there is no need to use the update pannel.

Upvotes: 4

Related Questions