passing parameter to javascript function

A

alf

Hi, how can I pass a value from ASP.NET to a javascript function in the
client-side ?? my problem is appening the ' at beginin and end of the
argument:
href=<%# "javascript:myFunction(" +
HttpUtility.UrlEncode(DataBinder.Eval(Container.DataItem,"id").ToString()) +
")" %>

the previous line will generate:
href=javascrip:myFunction(25)

but the real call to a function should be:
href=javascrip:myFunction('25')

and every time that I try to concat + "'" + in the asp.net code I get an
error saying that the instruction is not well formed..

thanks for any help
 
Joined
Apr 1, 2011
Messages
1
Reaction score
0
passing c# parameter in JavaScript

Dears,
I tried to pass a c# parameter in JavaScript but I got an error.

Line Code:
onclientclick="expand_shrink(<%# Eval("ID") %>)"


Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Server tags cannot contain <% ... %> constructs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top