Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Pass Variable to Javascript from ASP.NET

Posted on 2014-12-08
8
Medium Priority
?
136 Views
Last Modified: 2014-12-13
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" />
0
Comment
Question by:AJ0718
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 40487353
<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

0
 

Author Comment

by:AJ0718
ID: 40487420
Nope; same parser error.
0
 
LVL 58

Expert Comment

by:Gary
ID: 40487454
<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

0
Plesk WordPress Toolkit

Plesk's WordPress Toolkit allows server administrators, resellers and customers to manage their WordPress instances, enabling a variety of development workflows for WordPress admins of all skill levels, from beginners to pros.

See why 2/3 of Plesk servers use it.

 

Author Comment

by:AJ0718
ID: 40487553
Same problem.  I'm beginning to think this maybe isn't possible...
0
 
LVL 58

Expert Comment

by:Gary
ID: 40487568
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

0
 

Accepted Solution

by:
AJ0718 earned 0 total points
ID: 40487892
Thanks for trying but it had to be a server control so I could bind the data.  You might be interested in how I finally solved it.  I had to make it a command button and then the command passes the argument and triggers the Javascript function in the code behind.
<asp:LinkButton ID="btnRegistered" runat="server" Text="See Who Has Registered" CssClass="readmore"
                                            CommandName="TripList" CommandArgument='<%# Eval("TripID") %>' />
0
 
LVL 58

Expert Comment

by:Gary
ID: 40487895
Ahh right, select your own answer as the comment
0
 

Author Closing Comment

by:AJ0718
ID: 40497777
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.
0

Featured Post

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A publishing tool, a Version Control System, or a Collaboration Platform! These can be some of the defining words for the two very famous web-hosting Git repositories: Bitbucket and Github. Git is widely used amongst the programmers and developers f…
It’s a strangely common occurrence that when you send someone their login details for a system, they can’t get in. This article will help you understand why it happens, and what you can do about it.
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question