Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 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 March 27th, 2012, 04:00 AM
Registered User
 
Join Date: Mar 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Planet wrox sample website: Loss of ViewState

Hi to all,
This refers to the sample website "Planet Wrox" downloaded from p2p. I added a page "PictureDetails.aspx" in the "PhotoAlbums" folder so that it shows an enlarged image of the thumbnail that is clicked in the "Gigpics" page. After seeing the full image when I navigate back (either by pressing back button of browser or by clicking Gigpics link the dropdown goes back to the the first item in choice and the thumbnails disappear.

I checked the viewstate propery of the dropdown list, the image listview and also added "enableviewstate = "True" in the page directive.

Still I cannot understand why it the drop down goes back to the first element and the thumbnails vanish.

Any help in solving this will be highly appreciated.

One more feature I am thinking of adding is to display the date of uploading below all the thumbnails in the gigpics page. The system date should be automatically added whenever a user uploads an image. I added a column "DtUpLded" in the "Picture" table but how to populate it with current date?

Regards

Sirish.

========================================
Pages & codes added:
source of PictureDetails.aspx
-----------------------------------------
Code:
<%@ Page Language="VB" MasterPageFile="~/MasterPages/MasterPage.master" AutoEventWireup="false" CodeFile="PictureDetails.aspx.vb" Inherits="_Default" Title="Full Size Image" %>

<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" Runat="Server">
    <asp:Image ID="image1" runat="server" ImageAlign="Middle" Width="600" />
</asp:Content>
------------------------------------------

code of PictureDetails.aspx.vb
-----------------------------------------------------
Code:
Partial Class _Default
    Inherits BasePage

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub
    Protected Sub Image1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Image1.Load
        Dim imgUrl As String = Request.QueryString.Get("ImageUrl")
        image1.ImageUrl = imgUrl
    End Sub
End Class
------------------------------------------------------------------

Added the following code under ItemTemplate of the Listview to create the Hyperlink for each thumbnail

-----------------------------------------------------------
Code:
<asp:HyperLink ID = "HyperLink1" runat="server" NavigateUrl= '<%# "PictureDetails.aspx?ImageUrl="+Eval("ImageUrl") %>' >
						<asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("ImageUrl") %>' ToolTip='<%# Eval("ToolTip")%>' />
						</asp:HyperLink>
------------------------------------------------------------------

Last edited by sirish_kumar; March 27th, 2012 at 04:14 AM.. Reason: Wanted to post some additions
 
Old March 27th, 2012, 04:21 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

This is not related to ViewState or control state, but to AJAX. The pictures are loaded through an AJAX call because the entire list control is wrapped in an UpdatePanel. The browser doesn't keep track of these changes so when you click Back, it loads the page it initially loaded and doesn't reapply the AJAX call. A few ways to fix this:

1. Modify the list page so it responds to IDs in the Query String as well. That way, when an ID is found in the query string you can preselect the right item in the drop down list. Then in the details page, supply a "back" link that submits the photo album ID.

2. Drop the UpdatePanel.

3. Implement AJAX history: https://www.google.com/#q=implement+history+UpdatePanel

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!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Cant Find The Planet Wrox Project in source dubyaohohdee BOOK: Beginning ASP.NET 4 : in C# and VB 3 November 4th, 2010 09:32 AM
How to Publish WebSite Chapter 3 WroxUnited Sample hdpark BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 October 19th, 2007 08:24 AM
Wrox website HarishASP BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 August 21st, 2007 08:37 PM
Sample Website cleacock BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 4 January 9th, 2007 12:35 AM
Sample website for the second edition englere BOOK: ASP.NET Website Programming Problem-Design-Solution 0 January 16th, 2006 02:32 AM





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