Click here to Skip to main content
Rate this: bad
good
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.startAuto(0);
        });
 
        carousel.buttonPrev.bind('click', function () {
            carousel.startAuto(0);
        });
 
        // Pause autoscrolling if the user moves with the cursor over the clip.
        carousel.clip.hover(function () {
            carousel.stopAuto();
        }, function () {
            carousel.startAuto();
        });
    };
 
    jQuery(document).ready(function () {
        jQuery('#mycarousel').jcarousel({
            auto: 2,
            wrap: 'last',
            initCallback: mycarousel_initCallback
        });
    });
   
</script>
 
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
Edited 23-Dec-12 19:31pm
v2
Comments
aspnet_regiis -i at 24-Dec-12 0:38am
   
use the 'onchange' client side event of dropdown to call the javascript
Arun1990 at 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
good
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.
 
Response.Write("<script>mycarousel_initCallback(carousel);</script>");
 

 
Hope this helps.
Happy Coding Smile | :)
  Permalink  
v2
Rate this: bad
good
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>
        </asp:DropDownList>
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Hi,
 
You can also do like this:
 
You can add the
onchange="yourfunctionname()"
code to the dropdown and add the function in the script tag in the begining.
 
This is the best way to do...
 
Thanks
  Permalink  

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



Advertise | Privacy | Mobile
Web01 | 2.8.150305.1 | Last Updated 7 May 2013
Copyright © CodeProject, 1999-2015
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