Search code examples
c#asp.netsharepointupdatepanelweb-parts

How to execute a javascript function from a web part control wrapped inside an UpdatePannel?


I am working a SharePoint web part, which have a calendar control, now on calendar _VisibleMonthChanged event I am trying to call a javascript function like :

protected void cldEvents_VisibleMonthChanged(object sender, MonthChangedEventArgs e)
{
    var jQueryFn = "bindScrollBar();";
    ScriptManager.RegisterStartupScript(this, this.GetType(), "Test", jQueryFn, true);
}

But its not happening. (Note : the control is wrapped inside an Update Panel).

Please help achieving this.

Thanks in advance.


Solution

  • I think your RegisterStartupScript call should be like this:

    ScriptManager.RegisterStartupScript(updatePanel, updatePanel.GetType(), "Test", jQueryFn, true);
    

    Here you are passing page reference instead of UpdatePanel's.