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="listWindowO pen('<%# Eval("TripID") %>');return false;" UseSubmitBehavior="False" />
<asp:LinkButton ID="btnRegistered" runat="server" Text="See Who Has Registered" CssClass="readmore" OnClientClick="listWindowO
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" />
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" />
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Ahh right, select your own answer as the comment
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.
Open in new window