locked
"News_View.aspx?Articleid=" <----Syntax error RRS feed

  • Question

  • User-936568653 posted

    Can someone please direct me w/ the correct syntax of this:

     

    <script runat="server"> "News_View.aspx?Articleid=" &Cstr( Eval("ID"))</script>

     

    I cannot display this page on the server or otherwise since I get a syntax error where I have it underlined and bolded.

     

    Thanks,

     Justin

    Monday, April 30, 2007 9:59 PM

All replies

  • User-1639143169 posted

     

    It looks like you are trying to bind to a data srouce? maybe in a gridview or something.

     

    which would look something like :

        <form runat=server>
            <asp:Repeater id="MyRepeater" runat="server">
                <ItemTemplate>
                    Link for
                    <asp:HyperLink id=HyperLink1 Text='<%# DataBinder.Eval(Container.DataItem, "StringValue") %>' NavigateUrl='<%# "detailspage_vb.aspx?id=" + HttpUtility.UrlEncode(DataBinder.Eval(Container.DataItem,"StringValue")) %>' runat="server" />
                    <p>
                </ItemTemplate>
            </asp:Repeater>
        </form>

    However, from yoru code:

    " <script runat="server"> "News_View.aspx?Articleid=" &Cstr( Eval("ID"))</script>"

    it loos like you are doing something trying to set some sort of script variable, can you post more of the code, or clarify your intent?

    Tuesday, May 1, 2007 12:08 AM
  • User-936568653 posted

    Basically, I cannot display this page on the server or otherwise because of this line:

    <script runat="server"> "News_View.aspx?Articleid=" &Cstr( Eval("ID"))</script>

    Error 1 Element 'RolloverButton' is not a known element. This can occur if there is a compilation error in the Web site. C:\Inetpub\wwwroot\site\Default.aspx 46 43 C:\...\site\
    Error 2 Element 'RolloverButton' is not a known element. This can occur if there is a compilation error in the Web site. C:\Inetpub\wwwroot\site\Default.aspx 63 31 C:\...\site\
    Error 3 Syntax error. C:\Inetpub\wwwroot\site\Default.aspx 4 25 C:\...\site\ "News_View.aspx?Articleid="
    Error 4 Name 'ShowDuration' is not declared. C:\Inetpub\wwwroot\site\Default.aspx 4 71 C:\...\site\ </script>

    Below is the Default page: 

     

    <%@ Page Language="VB" MasterPageFile="~/Default.master" Title="Untitled Page" %>

    <%@ Register TagPrefix="Club" TagName="ImageThumbnail" Src="ImageThumbnail.ascx" %>

    <%@ Register TagPrefix="Club" Namespace="Clubsite" %>

    <script runat="server"> "News_View.aspx?Articleid=" &Cstr( Eval("ID"))</script>

    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">

    <div id="body">

    <!--Start of left column-->

    <div id="columnleft">

    <a name="content_start" id="content_start"></a>

    <div class="leftblock">

    <h2>

    Welcome</h2>

    <p>

    The Rastafarian Gang</p>

    </div>

    <div class="leftblock">

    <asp:LoginView ID="lv1" runat="server">

    <AnonymousTemplate>

    <h2>

    Login</h2>

    <div class="dashedline">

    </div>

    <asp:Login ID="Login1" runat="server">

    <LayoutTemplate>

    <h3 class="none">

    Log into My Club Site</h3>

    <fieldset>

    <legend class="none">Log into My Club Site</legend>

    <asp:Label runat="server" AssociatedControlID="UserName" ID="UserNameLabel">User name:</asp:Label>

    <br />

    <asp:TextBox runat="server" ID="UserName"></asp:TextBox>

    <asp:RequiredFieldValidator runat="server" ControlToValidate="UserName" ValidationGroup="Login1"

    ErrorMessage="User Name is required." ToolTip="User Name is required." ID="UserNameRequired">*</asp:RequiredFieldValidator>

    <p>

    </p>

    <asp:Label runat="server" AssociatedControlID="Password" ID="PasswordLabel">Password:</asp:Label>

    <br />

    <asp:TextBox runat="server" TextMode="Password" ID="Password"></asp:TextBox>

    <asp:RequiredFieldValidator runat="server" ControlToValidate="Password" ValidationGroup="Login1"

    ErrorMessage="Password is required." ToolTip="Password is required." ID="PasswordRequired">*</asp:RequiredFieldValidator>

    <p>

    </p>

    <asp:CheckBox runat="server" ID="RememberMe" Text="Remember me next time." />

    <p>

    </p>

    <Club:RolloverButton runat="server" ValidationGroup="Login1" Text="Login" ID="LoginButton"

    CommandName="Login" />

    <p>

    </p>

    <asp:Literal runat="server" ID="FailureText" EnableViewState="False"></asp:Literal>

    </fieldset>

    </LayoutTemplate>

    </asp:Login>

    </AnonymousTemplate>

    <LoggedInTemplate>

    <h2>

    Hello

    <asp:LoginName ID="LoginName1" runat="server" />

    </h2>

    <p>

    Welcome back to the clubsite.

    </p>

    <Club:RolloverButton runat="server" id="logout" text="Log off" onclick="logout_click" />

    </LoggedInTemplate>

    </asp:LoginView>

    </div>

    </div>

    <!--end columnleft-->

    <!--Start of right column-->

    <div id="columnright">

    <!-- Start of news list functionality -->

    <div class="rightblock">

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ProviderName="System.Data.SqlClient"

    ConnectionString="<%$ ConnectionStrings:Club %>" SelectCommand="SELECT top 5 [id], [itemdate], [title], [description], [photo] FROM [Announcements] order by itemdate desc">

    </asp:SqlDataSource>

    <h2>

    Recent news</h2>

    <div class="dashedline">

    </div>

    <asp:Repeater ID="DataList1" runat="server" DataSourceID="SqlDataSource1">

    <ItemTemplate>

    <div class="listitem">

    <div class="thumbnail">

    <a href='<%# "News_View.aspx?Articleid=" &Cstr( Eval("ID"))%>'>

    <Club:ImageThumbnail ID="ImageThumbnail2" runat="server" PhotoID='<%# Eval("photo") %>'

    NoPhotoImg="images/news.jpg" />

    </a>

    </div>

    <h3>

    <asp:Label ID="Label3" runat="server" Text='<%# Eval("itemdate","{0:d}") %>' />

    &nbsp;&nbsp;&nbsp;&nbsp; <a href='<%# "News_View.aspx?Articleid=" &Cstr( Eval("ID"))%>'>

    <asp:Label ID="Label4" runat="server" Text='<%# Eval("title") %>' />

    </a>

    </h3>

    <p>

    <asp:Label ID="Label2" runat="server" Text='<%# truncate(CStr(Eval("description"))) %>' />

    <a href='<%# "News_View.aspx?Articleid=" &Cstr( Eval("ID"))%>'>read more &raquo;</a>

    </p>

    <div class="clearlist"></div>

    </div>

    </ItemTemplate>

    </asp:Repeater>

    <div class="dashedline">

    </div>

    <a href="news_list.aspx">Read all news articles &raquo;</a>

    </div>

    <div class="rightblock">

    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:Club %>"

    SelectCommand="SELECT top 5 dbo.Events.id, dbo.Events.starttime, dbo.events.endtime, dbo.Events.title, dbo.Locations.title AS locationname FROM dbo.Events LEFT OUTER JOIN dbo.Locations ON dbo.Events.location = dbo.Locations.id WHERE (dbo.Events.starttime > GETDATE()) ORDER BY dbo.Events.starttime, dbo.events.id ">

    </asp:SqlDataSource>

    <h2>

    Upcoming Events</h2>

    <div class="dashedline">

    </div>

    <asp:GridView AutoGenerateColumns="False" DataSourceID="SqlDataSource2" ID="GridView1"

    runat="server" ShowHeader="False" Width="410px" CssClass="eventlist" GridLines="None">

    <Columns>

    <asp:BoundField DataField="starttime" DataFormatString="{0:d}" HeaderText="starttime"

    SortExpression="starttime"></asp:BoundField>

    <asp:TemplateField>

    <ItemTemplate>

    <asp:HyperLink ImageUrl="images/icon_event.gif" runat="server" NavigateUrl='<%# Eval("id","Events_download.ashx?Eventid={0}") %>' />

    </ItemTemplate>

    </asp:TemplateField>

    <asp:TemplateField HeaderText="id" InsertVisible="False" SortExpression="id">

    <ItemTemplate>

    <asp:Label ID="Label1" runat="server" Text='<%# ShowDuration(Eval("starttime"),Eval("endtime")) %>' />

    </ItemTemplate>

    </asp:TemplateField>

    <asp:HyperLinkField DataNavigateUrlFields="id" DataNavigateUrlFormatString="events_view.aspx?eventid={0}"

    DataTextField="title"></asp:HyperLinkField>

    <asp:BoundField DataField="locationname" HeaderText="locationname" SortExpression="locationname"

    NullDisplayText=""></asp:BoundField>

    </Columns>

    </asp:GridView>

    <div class="dashedline">

    </div>

    <a href="Events_list.aspx">View all events &raquo;</a>

    </div>

    </div>

    <div class="clear2column"></div>

    </div>

    </asp:Content>

    Tuesday, May 1, 2007 4:48 PM