Solved

Server tag is not well formed

Posted on 2011-02-15
11
1,397 Views
Last Modified: 2012-05-11
Hi,

I am getting a Server tag is not well formed.  doesn't seem to like my eval expression.

Below is what I have

<asp:HyperLink NavigateUrl="javascript:switchViews( '<%# Eval("TimePeriodId") %>' )" ID="HyperLink1" runat="server" Text='<%# Eval("TimePeriodId") %>' />

Thank you
0
Comment
Question by:yechan
[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
  • 2
  • +1
11 Comments
 
LVL 10

Expert Comment

by:GlobaLevel
ID: 34897407
I am not sure what you are tyring to do here...but it appears that the error is in your javascript...you would have to post that code....

also,,if you are tyring to pull a value from the server side..you have use a hiddenfield...
0
 
LVL 1

Author Comment

by:yechan
ID: 34897447
heya,

i don't think the error code is inside the javascript.  At this point, I can't even compile without even getting a ""The Server tag is not well formed".  When I remove NavigateUrl=..... asp.net compiles just fine.
0
 
LVL 10

Expert Comment

by:GlobaLevel
ID: 34897485
so you need a hiddenfield...on the client side...
 <asp:HiddenField runat="server" ID="sessionDuration" />

------------
..in the code behind...whatever you want...
 If Session("session_duration") Is Nothing Then
                Session("session_duration") = "20"
    End If
   sessionDuration.Value = Session("session_duration").ToString()

-------

also in client side you need your javascript....in the head section ...something like this...

  <script language="javascript" type="text/javascript">
    var sessionDuration;
    var showTimer;
    var hideTimer;
    window.onload = function () {
 
       
        sessionDuration = document.getElementById("<%= sessionDuration.ClientID %>").value;
        showTimer = setInterval('if(--sessionDuration>0) document.getElementById("<%= Label17.ClientID %>").innerHTML = document.getElementById("<%= attendant_name.ClientID %>").value + " is typing... ";else { clearInterval(showTimer);clearInterval(hideTimer); }', Math.floor(Math.random() * 6000));
        hideTimer = setInterval('document.getElementById("<%= Label17.ClientID %>").innerHTML = "";', 888);
   
    }
   
 
   
   
    </script>

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Expert Comment

by:GlobaLevel
ID: 34897511
then make sure your code behind is in shape...put a breakpoint on the code behind..and trace/step thru..to see where it dies at...most likely you are missing smoething in your code behine...i dont know what 'TimePeriodId'..is trying to do...
0
 
LVL 54

Expert Comment

by:Huseyin KAHRAMAN
ID: 34897606
try

<asp:HyperLink NavigateUrl='javascript:switchViews( "<%# Eval("TimePeriodId") %>" )' ID="HyperLink1" runat="server" Text='<%# Eval("TimePeriodId") %>' />

0
 
LVL 10

Assisted Solution

by:GlobaLevel
GlobaLevel earned 250 total points
ID: 34897652
does this work?
<asp:HyperLink NavigateUrl="javascript:switchViews( '<%# Eval("TimePeriodId") %>' )" ID="HyperLink2" runat="server" Text="<%# Eval('TimePeriodId') %>" />
0
 
LVL 11

Expert Comment

by:SAMIR BHOGAYTA
ID: 34898512
0
 
LVL 1

Author Comment

by:yechan
ID: 34902151
Hi HainKurt and GlobalLevel,

I have tried both of your suggestions but to no avail.

The good news though is that if I try HainKurt's suggestion, I get an error message something like this:

Message: Expected ')'
Line: 1
Char: 25
Code: 0
URI: http://localhost:49216/DynmicGridView/Default.aspx

then I looked at the source code and I see the following:


it appears that the < > etc are being escaped by asp.net

<a id="MainGridView_ctl02_HyperLink1" href="javascript:switchViews( &quot;&lt;%# Eval(&quot;TimePeriodId&quot;) %>&quot; );">50</a>

Open in new window

0
 
LVL 54

Accepted Solution

by:
Huseyin KAHRAMAN earned 250 total points
ID: 34903389
what about this

<a href='javascript:switchViews("<%# Eval("TimePeriodId") %>" )'><%# Eval("TimePeriodId") %></a>
or this
<a href="javascript:switchViews('<%# Eval("TimePeriodId") %>' )"><%# Eval("TimePeriodId") %></a>

do you really need server side?
0
 
LVL 1

Author Comment

by:yechan
ID: 34923373
Heya,

yes I do because this code is being used inside a GridView and I have a JaveScript that toggles the visiblity on and off  based on a unique id.
0
 
LVL 1

Author Comment

by:yechan
ID: 35069699
Time to close it out.  Been playing with jQuery and it seems OK.  thanks for all the input.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

729 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