Jason Livengood
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
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" />
Try the below code:
<asp:Linkbutton id="LinkButton1" Text='<%# Eval("StudyID_i") %>' CommandArgument='<%# Eval("StudyID_i")%>' onclientclick="Navigate(<%# Eval("StudyID_i") %>))" runat="Server" />
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you need to define it in single quotes else JS will throw an error, something like this
onclientclick="Navigate('< %# Eval('StudyID_i') %>'))"
onclientclick="Navigate('<
@shinug,
That is what I posted, please check the post of others before posting...
That is what I posted, please check the post of others before posting...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
onclientclick="Navigate( this.innerText );" Seems to be the best solution. At least for me. Thank you all for your help with this.
onclientclick="Navigate(th
or
onclientclick="Navigate(th