Pass ItemTemplate field value as a paramter to Javascript function ASP.NET

Posted on 2013-01-15
Medium Priority
Last Modified: 2013-01-15
How can I pass a value for link button onClientclick, which call a JS function which accepts two values like this:
 <asp:LinkButton ID="lnkEdit" runat="server" Text="Change" Font-Underline="false"
   OnClientClick="return edit('EDIT',  "<%= Eval( "ID"));" ForeColor="Blue" />'
 <asp:Label ID="lblID" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "ID")%>'Style="display: none" />

Open in new window

I was getting error Server Tag not well formed, and also is it the way to pass the template field value or I need to do document.getelementbyid.
Question by:ASPDEV
LVL 41

Accepted Solution

guru_sami earned 2000 total points
ID: 38780370
try this:
 OnClientClick='<%# Eval("ID", "return edit(\"EDIT\",{0});") %>' 

Open in new window


Author Closing Comment

ID: 38780496

Featured Post

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

607 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