Navi's

Necessity, the mother of invention

  • Visitor Map

    Locations of Site Visitors
  • Flag Counter

    free counters

Pass Eval value in javascript function from GridView

Posted by Navi's on February 2, 2011


In Gridview, some times we need to pass (Eval(“Column”)) value in javascript function on LinkButton or HyperLink. But you can not directly pass eval value in javascript function like this

 
<asp:LinkButton id='lnk' runat='server' OnClientClick='javascript:somefun('<%# Eval("columnname") %>')' />

This will give error. To resolve this problem we need to use bellow syntax..

 
<asp:LinkButton id='lnk' runat='server' OnClientClick='<%#Eval("columnname","javascript:somefun({0});")%>' />

This is the best way to pass eval value in javascript function from GridView’s LinkButton / HyperLink.

enjoy :)

Reference: http://bit.ly/hSP1LI

About these ads

9 Responses to “Pass Eval value in javascript function from GridView”

  1. guru2friends said

    Thanks Navi, This is what I looked for long time. It is working fine.
    Guru

  2. shwetamber said

    its not working for me. The Final html will be

    Now javascript function will gives error – Abheri is not defined.

    I don’t get the alert message. below is javascript function.

    function test(pnl)
    {
    alert(‘test’);
    }

  3. malek said

    if we have 2 eval value; how can we pass them?

  4. kinjal shah said

    Thank’s Navi

  5. Anna-Pia said

    Thank you! After going through tons of suggestions this finally helped me out.

  6. subbu said

    Hi All,
    The below code works fine for me in the ImageButton
    OnClientClick=”

    Please help me out how to implement the same in OnClientClicked, i am using using the <Telerik:RadButton

    OnClientClicked –

  7. diggerz said

    shot maamz. exactly what i was looking for

  8. Bibz said

    Thanks I wasted 4 hrs searching for right answer and trying many answers…none could help me until I found this. Gr8 job…:)

  9. Miguel said

    Muchas gracias me has ahorrado varias horas de pruebas

    Translated : Thank you very much you’ve saved me several hours of testing

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

Join 61 other followers

%d bloggers like this: