?
Solved

Trying to pass value to Javascript in a LinkButton

Posted on 2011-02-23
7
Medium Priority
?
841 Views
Last Modified: 2012-05-11
I have a Linkbutton control. When it is clicked I would like to pass a value to a Javascript funcition  to open a pop-up window. Linkbutton and Javascript function are below. I cannot figure out how to pass the studyid (which is basically the text value of the LinkButton) in the OnClientClick=Navigate(???). If I hard code a value it works fine.

Any help would be greatly appreciated.

Jason


function Navigate(StudyID_i) {
            javascript: window.open("TechDetail.aspx?studyid="+ StudyID_i);
        } 

<asp:Linkbutton id="LinkButton1" Text='<%# Eval("StudyID_i") %>' CommandArgument='<%# Eval("StudyID_i")%>'  onclientclick="Navigate(????))" runat="Server" />

Open in new window

0
Comment
Question by:jazzcatone
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 40

Expert Comment

by:gurvinder372
ID: 34967390
try

onclientclick="Navigate(this.value)"

or

 onclientclick="Navigate(this.getAttribute('value'))"  
0
 
LVL 8

Expert Comment

by:PagodNaUtak
ID: 34967432
Try the below code:
<asp:Linkbutton id="LinkButton1" Text='<%# Eval("StudyID_i") %>' CommandArgument='<%# Eval("StudyID_i")%>'  onclientclick="Navigate(<%# Eval("StudyID_i") %>))" runat="Server" />

Open in new window

0
 
LVL 8

Assisted Solution

by:PagodNaUtak
PagodNaUtak earned 400 total points
ID: 34967436
Typo graphical error.
Please disregard my post above but instead try the below code:
<asp:Linkbutton id="LinkButton1" Text='<%# Eval("StudyID_i") %>' CommandArgument='<%# Eval("StudyID_i")%>'  onclientclick="Navigate(<%# Eval('StudyID_i') %>))" runat="Server" />

Open in new window

0
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
LVL 17

Expert Comment

by:Shinesh Premrajan
ID: 34967483
you need to define it in single quotes else JS will throw an error, something like this

onclientclick="Navigate('<%# Eval('StudyID_i') %>'))"
0
 
LVL 8

Expert Comment

by:PagodNaUtak
ID: 34967594
@shinug,

That is what I posted, please check the post of others before posting...
0
 
LVL 20

Accepted Solution

by:
Proculopsis earned 1600 total points
ID: 34968622

This should be as simple as:

  onclientclick="Navigate( this.innerText );"
0
 

Author Comment

by:jazzcatone
ID: 34969984
onclientclick="Navigate( this.innerText );"  Seems to be the best solution. At least for me. Thank you all for your help with this.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

743 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