Error "Handler must be a function"

Posted on 2008-09-29
Last Modified: 2010-04-21

I have a problem with an AJAX calendar control on a gridview.

I add javascript to it on the row bound method for the OnClientDateSelectionChanged event.

Dim js As String = "dosomething('" & DaysX.ClientID & "','" & DaysY.ClientID & "')"
calendarEx.OnClientDateSelectionChanged = js
In javascript I have a function declared as


If the function is simply dosomething() no parameters the OnClientDateSelectionChanged  works

However I need to add parameters. When I add parameters the javascript is called followed by an error "Handler must be a function error"

Thanks in advance for assistance.
Question by:rwallacej
  • 3
  • 2
LVL 25

Assisted Solution

by:Luis Pérez
Luis Pérez earned 200 total points
ID: 22596294
Try this:

calendarEx.OnClientDateSelectionChanged = function() {

I think it will work for you.

Expert Comment

ID: 22596358
in your code behind.......
Dim js As String = "dosomethingWithParams()"
calendarEx.OnClientDateSelectionChanged = js

In your script on the aspx......
function dosomethingWithParams()"
{dosomething('<%= DaysX.ClientID%>','<%=DaysY.ClientID%>');

Expert Comment

ID: 22596377
remove the quote at the end of the js function definition, it's a typo
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!


Author Comment

ID: 22596585
thanks for inputs;

hi diveblue
I made a slight mod so its like this
"javascript:function(){" & "dosomething(" & DaysX.ClientID & "," & DaysY.ClientID & ");};" to pickup the ID for each row. It does compile with no errors but javascript doesn't run - no alert message or anything.

hi DiveblueD
I like this idea however it doesn't work in my case. There are multiple DaysX client IDs etc as it is on  a gridview with each row having different IDs ( can't compile the page like this) so it didnt' work


Accepted Solution

Diveblue earned 300 total points
ID: 22596760
Sounds like you'll need to do some work in the onitemCreated event of the you can change attributes of the INSTANCE of the clendar that is on the row....

Author Closing Comment

ID: 31501170
thanks for help.....this got me on road to solution

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now