Link to home
Start Free TrialLog in
Avatar of AJ0718
AJ0718

asked on

Pass Variable to Javascript from ASP.NET

I have what is probably a simple syntactical problem.  As background, the button is in a nested ListView, but it seems like it should be pretty straightforward.  The js function simply takes the TripID variable and opens a popup window with the data.  The error message is that the server tag is not well formed which makes me think it is a matter of quotes and single ticks but I'm not having any luck finding an example of how best to fix this.  Thanks for the help.

<asp:LinkButton ID="btnRegistered" runat="server" Text="See Who Has Registered" CssClass="readmore" OnClientClick="listWindowOpen('<%# Eval("TripID") %>');return false;" UseSubmitBehavior="False" />
Avatar of Gary
Gary
Flag of Ireland image

<asp:LinkButton ID="btnRegistered" runat="server" Text="See Who Has Registered" CssClass="readmore" OnClientClick="listWindowOpen('<%# Eval(""TripID"") %>');return false;" UseSubmitBehavior="False" /> 

Open in new window

Avatar of AJ0718
AJ0718

ASKER

Nope; same parser error.
<asp:LinkButton ID="btnRegistered" runat="server" Text="See Who Has Registered" CssClass="readmore" OnClientClick="listWindowOpen('<%# Eval(\"TripID\") %>');return false;" UseSubmitBehavior="False" /> 

Open in new window

Avatar of AJ0718

ASKER

Same problem.  I'm beginning to think this maybe isn't possible...
Remove the runat="server"

 <asp:LinkButton ID="btnRegistered" Text="See Who Has Registered" CssClass="readmore" OnClientClick="listWindowOpen('<%# Eval("TripID") %>');return false;" UseSubmitBehavior="False" />

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of AJ0718
AJ0718

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
Ahh right, select your own answer as the comment
Avatar of AJ0718

ASKER

This had to be a server control to bind the value. By making it a command button and writing the item command handler in the code behind, I could then register the script and it runs.