Click here to Skip to main content
12,690,140 members (30,269 online)
Rate this:
Please Sign up or sign in to vote.
See more: ASP.NET
I have a java script:

<script type="text/javascript">

    function mycarousel_initCallback(carousel) {
        // Disable autoscrolling if the user clicks the prev or next button.
        carousel.buttonNext.bind('click', function () {

        carousel.buttonPrev.bind('click', function () {

        // Pause autoscrolling if the user moves with the cursor over the clip.
        carousel.clip.hover(function () {
        }, function () {

    jQuery(document).ready(function () {
            auto: 2,
            wrap: 'last',
            initCallback: mycarousel_initCallback

This java script is put in master page and i want to call this java script in drop down selected index changed, dropdown is placed in user control So how can i do this plz help me
Posted 23-Dec-12 19:24pm
Updated 23-Dec-12 19:31pm
aspnet_regiis -i 24-Dec-12 0:38am
use the 'onchange' client side event of dropdown to call the javascript
Arun1990 24-Dec-12 0:44am
sir plz put eject line then how i call "function mycarousel_initCallback(carousel)" and i pass "carousel" in that function, because with out parameter function is call easily,
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Hi Arun,

Try using Response.Write() method for this but before this please ensure that the JS file is referenced properly in the output HTML.


Hope this helps.
Happy Coding :)
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

In your code behind write as below.

protected void Page_Load(object sender, EventArgs e)
        ddl.SelectedIndexChanged += new EventHandler(ddl_SelectedIndexChanged);
        if (!Page.IsPostBack)
            ddl.Attributes.Add("onchange", "mycarousel_initCallback(ddl);");

    protected void ddl_SelectedIndexChanged(object sender, EventArgs e)
       //Your Code

And your ASPX will be like:
<asp:DropDownList ID="ddl" runat="server"  AutoPostBack="true">
        <asp:ListItem Text="a" Value="a"></asp:ListItem>
         <asp:ListItem Text="b" Value="b"></asp:ListItem>
Rate this: bad
Please Sign up or sign in to vote.

Solution 3


You can also do like this:

You can add the
code to the dropdown and add the function in the script tag in the begining.

This is the best way to do...


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170117.1 | Last Updated 7 May 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100