passing parameter to javascript function

Discussion in 'ASP .Net' started by alf, Feb 4, 2004.

  1. alf

    alf Guest

    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
    alf, Feb 4, 2004
    #1
    1. Advertising

  2. alf

    alf Guest

    sorry I got it !!!

    using \" will generate the ".
    thanks any way.

    "alf" <> wrote in message
    news:%...
    > 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
    >
    >
    alf, Feb 4, 2004
    #2
    1. Advertising

  3. alf

    azoozey

    Joined:
    Apr 1, 2011
    Messages:
    1
    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.
    azoozey, Apr 1, 2011
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bishoy George
    Replies:
    8
    Views:
    10,860
    Bishoy George
    Sep 28, 2005
  2. Newsgroup - Ann
    Replies:
    5
    Views:
    592
    John Carson
    Jul 30, 2003
  3. Azdo
    Replies:
    2
    Views:
    429
  4. Mister B
    Replies:
    8
    Views:
    531
    Nick Keighley
    Aug 26, 2010
  5. AzamSharp
    Replies:
    2
    Views:
    163
Loading...

Share This Page