Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bind a value to a javascript method as parameter

I'm getting error on binding a javascript method call using Eval(). Following is the line of code within a repeater control:

<asp:Button ID="View" runat="server" Text="View" CommandName="View" OnClientClick="OpenInNewWindow(<%# Eval("JobID")%>)">
                        </asp:Button>

I need to get the value jobId for that javascript method. Can anyone help me out?

like image 595
NewBie Avatar asked Feb 20 '26 16:02

NewBie


1 Answers

Try this:

<asp:Button ID="AddCartButton" runat="server" Text="Add To Cart" onClick="AddCartButton_Click" 
     OnClientClick='<%# Eval("JobID", "OpenInNewWindow(\"{0}\").ToString()") %>'/>

each single quote disorientate markup parser. Except this one, expression evaluated practically the same way as regular C# expression

Corrected the syntax

like image 87
sajanyamaha Avatar answered Feb 22 '26 05:02

sajanyamaha



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!