Link to home
Start Free TrialLog in
Avatar of Jason Livengood
Jason LivengoodFlag for United States of America

asked on

Trying to pass value to Javascript in a LinkButton

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

Avatar of Gurvinder Pal Singh
Gurvinder Pal Singh
Flag of India image

try

onclientclick="Navigate(this.value)"

or

 onclientclick="Navigate(this.getAttribute('value'))"  
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

SOLUTION
Avatar of PagodNaUtak
PagodNaUtak
Flag of Philippines image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
you need to define it in single quotes else JS will throw an error, something like this

onclientclick="Navigate('<%# Eval('StudyID_i') %>'))"
@shinug,

That is what I posted, please check the post of others before posting...
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jason Livengood

ASKER

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