Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4.5 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4.5: in C# and VB by Imar Spaanjaars; ISBN: 978-1-118-31180-6
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4.5 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 16th, 2014, 11:49 AM
Registered User
 
Join Date: Dec 2013
Posts: 6
Thanks: 3
Thanked 0 Times in 0 Posts
Default Ch 17: Hyperlink from Favorite Reviews fails

Now on Ch 17 - had a break after last issue! I have made the changes to default.aspx in the Reviews folder and everything builds OK with no errors. I view the page in IE, after logging in, and it displays everything as it should. I hover over one of the hyperlinks and the url looks correct but when I click it I get an 404 error - page not found.

I then went back to the All Reviews page and the hyperlinks look the same and in this page they work fine. I've compared the HTML in both pages and the <asp:hyperlink> code looks identical. So, I'm confused.

HMTL from default.aspx (Reviews folder):
HTML Code:
    <asp:Repeater ID="GenreRepeater" runat="server">
        <HeaderTemplate>
            <p>Below you will find a list with reviews for your favourite music genres.</p>
        </HeaderTemplate>
        <ItemTemplate>
            <h3><asp:Literal ID="Literal1" runat="server" Text= '<%# Eval("Name")%>'></asp:Literal></h3>
            <asp:Repeater ID="ReviewRepeater" runat="server" DataSource='<%# Eval("Reviews")%>' ItemType="PlanetWroxModel.Review">
                <ItemTemplate>
                    <asp:HyperLink ID="HyperLink1" runat="server" Text='<%# Item.Title%>' NavigateUrl='<%# "ViewDetails.apsx?ReviewId=" + Item.Id.ToString()%>'>
                    </asp:HyperLink>
                </ItemTemplate>
                <SeparatorTemplate>
                    <br />
                </SeparatorTemplate>
            </asp:Repeater>
        </ItemTemplate>
    </asp:Repeater>

Hyperlink HTML from ALL.aspx:
HTML Code:
     <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# "ViewDetails.aspx?ReviewId=" + Item.Id.ToString() %>' Text='<%# Item.Title %>'></asp:HyperLink>
Any thoughts? I can't spot any difference between these two. Perhaps something is wrong elsewhere but I haven't found it.

Many thanks.

Paul
 
Old January 16th, 2014, 12:20 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Can you show the HTML from the browser? Also, are you sure ViewDetails.aspx exists and is placed in the correct folder?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old January 16th, 2014, 01:13 PM
Registered User
 
Join Date: Dec 2013
Posts: 6
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Quote:
Can you show the HTML from the browser?
I have just copied the relevant bit - did you want more?

HTML Code:
            <p>Below you will find a list with reviews for your favourite music genres.</p>
        
            <h3>Hard Rock</h3>
            
                    <a id="cpMainContent_GenreRepeater_ReviewRepeater_0_HyperLink1_0" href="ViewDetails.apsx?ReviewId=6">Death Magnetic by Metallica</a>
                
                    <br />
                
                    <a id="cpMainContent_GenreRepeater_ReviewRepeater_0_HyperLink1_1" href="ViewDetails.apsx?ReviewId=14">Travelling the Face of the Globe by Oi Va Voi - A genuinely fresh and enthralling sound</a>
                
        
            <h3>Pop</h3>
            
                    <a id="cpMainContent_GenreRepeater_ReviewRepeater_1_HyperLink1_0" href="ViewDetails.apsx?ReviewId=8">Wait for Evolution by De Staat</a>
                
                    <br />
                
                    <a id="cpMainContent_GenreRepeater_ReviewRepeater_1_HyperLink1_1" href="ViewDetails.apsx?ReviewId=18">Sounds Of The Universe by Depeche Mode - Overhyped or a master piece?</a>
                
                    <br />
                
                    <a id="cpMainContent_GenreRepeater_ReviewRepeater_1_HyperLink1_2" href="ViewDetails.apsx?ReviewId=25">This is the title</a>
                
        
Quote:
Also, are you sure ViewDetails.aspx exists and is placed in the correct folder?
ViewDetails is in the Reviews folder, so I think that's a "Yes". It does exist and the hyperlinks from the All.aspx page work correctly and do bring up the ViewDetails page with the correct review.

Paul
 
Old January 17th, 2014, 03:45 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Ah, now I see what the problem is:

Code:
<asp:HyperLink ID="HyperLink1" runat="server" Text='<%# Item.Title%>' NavigateUrl='<%# "ViewDetails.apsx?ReviewId=" + Item.Id.ToString()%>'>
Note the extension. You have apsx instead of aspx ;-)

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following 2 Users Say Thank You to Imar For This Useful Post:
paulf (January 17th, 2014)
 
Old January 17th, 2014, 05:28 AM
Registered User
 
Join Date: Dec 2013
Posts: 6
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Doh!

Sorry - sometimes you just can't see the wood for the trees, especially when you know what it ought to say and the brain "auto-corrects". I'll try to come up with something more challenging in future!!

Thank you.

Paul





Similar Threads
Thread Thread Starter Forum Replies Last Post
Ch. 17, Exercise 1, p. 652 krzys18asp BOOK: Beginning ASP.NET 4 : in C# and VB 2 May 15th, 2013 05:12 AM
Ch 17. Emergency Responder plagoon BOOK: Professional Android 4 Application Development 0 January 2nd, 2013 03:40 PM
Chapter 4: Pages 130 - 132 Querying for reviews & Displaying the reviews FlaUsa BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 January 24th, 2012 01:55 AM
CH 17 - Assemblies equintana71 BOOK: Professional C# 2008 ISBN: 978-0-470-19137-8 1 May 17th, 2011 09:20 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.