Solved

Error "Handler must be a function"

Posted on 2008-09-29
6
737 Views
Last Modified: 2010-04-21
Hi

I have a problem with an asp.net 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

dosomething(varA,varB)

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.
0
Comment
Question by:rwallacej
  • 3
  • 2
6 Comments
 
LVL 25

Assisted Solution

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

calendarEx.OnClientDateSelectionChanged = function() {
        dosomething(DaysX.ClientID,DaysY.ClientID);
}

I think it will work for you.
0
 
LVL 3

Expert Comment

by:Diveblue
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%>');
}
0
 
LVL 3

Expert Comment

by:Diveblue
ID: 22596377
remove the quote at the end of the js function definition, it's a typo
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 

Author Comment

by:rwallacej
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 (asp.net can't compile the page like this) so it didnt' work

0
 
LVL 3

Accepted Solution

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

Author Closing Comment

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

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

772 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