Passing a parm to onClientClick

See code below.   The asp code works.  As does the VB.NET in the code behind.

What I want to do is in the asp code pass the PrimaryKey.Text as a parm, instead of where the 4 is.  Syntax-wise, I cannot get this to work.  

VB.NET CODE:

ShowButton1.Attributes.Add("onClick", "ShowRecord('" & PrimaryKey.Text & "');")


ASP.NET CODE

<asp:ImageButton runat="server" id="ShowButton1" causesvalidation="False" commandname="Redirect" cssclass="button_link" imageurl="../Images/icon_view.gif" tooltip="Show Funding Request"
onclientclick="return ShowRecord(4);">            
      </asp:ImageButton>
LVL 1
HLRosenbergerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Johny BravoCommented:
It should be,

 ShowButton1.Attributes.Add("onclick", "javascript:return ShowRecord('"+PrimaryKey.Tect+"')");
0
HLRosenbergerAuthor Commented:
I can get to it work in VB code.   What I cant get to work is the aspx code.  How do this change this, and replace the 4 with   'PrimaryKey.text' ?


<asp:ImageButton runat="server" id="ShowButton1" causesvalidation="False" commandname="Redirect" cssclass="button_link" imageurl="../Images/icon_view.gif" tooltip="Show Funding Request"
onclientclick="return ShowRecord(4);">            
      </asp:ImageButton>
0
CodeCruiserCommented:
Assuming that this code is within a bigger control that is bound to data, you can change

onclientclick="return ShowRecord(4)

to

onclientclick=<%# string.format("return ShowRecord({0});", Eval("PrimaryKeyColumnName")) %>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HLRosenbergerAuthor Commented:
CodeCruiser:

My PrimaryKey is a textbox control within a repeater control.  Will your suggestion with in this case?
0
HLRosenbergerAuthor Commented:
thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.