Click here to Skip to main content
15,884,029 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

When I am trying to call javascript functio from RegisterClientScriptblock showing error like

Code:
JavaScript
RegisterClientScriptBlock("fn", "<script>getDueDate('" & txtDueDate.Text & "');</script>")


Error: The value of the property 'getDueDate' is null or undefined, not a Function object.



Please suggest me in solving this.
Posted
Updated 29-Sep-15 1:26am
v2
Comments
Palash Mondal_ 29-Sep-15 7:46am    
Is getDueDate() already defined in your js file?

Try this-
VB
RegisterClientScriptBlock(GetType(),"fn", "<script>getDueDate('" & txtDueDate.Text & "');</script>", true)


Hope, it helps :)
 
Share this answer
 
Comments
Baroor 29-Sep-15 7:39am    
@Suvendu Shekar, it is not working , asking for type expected error at GetType().
First off you need to appreciate that you're not calling javascript from your server code, all registerclientscriptblock does is add javascript to the page you are rendering. In order for your js to work you need a javascript function called getDueDate defined on the page and it has to be defined somewhere at the top so that it is included before your script block. View the source to see where your script is being added and where your getDueDate function is defined and amend as needed.

If getDueDate is a server function this isn't going to work, you can only call javascript, and also remember that you are hard-coded the function to pass whatever is in txtDueDate.Text at the time the page is rendered.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900