Re: Thumbnail control does not update after images added/removed.

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Your code to show the photos may be happening before the photo is being
added. In this case, you need to force a re-show of the photos. You could
put your photo-showing code into a function so that you can call it again
from your insert and delete functions.


--
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

"RB" <owmdkbqzikigpu@xxxxxxxxxxxxxx> wrote in message
news:aLCdncTAJJhf0kjbnZ2dneKdnZydnZ2d@xxxxxxxxxxxxxxxxx
Hi there,

I'm having a problem with an ASP.NET/VB.NET Control I am writing.

The control is a simple gallery control, which shows a set of thumbnails
(using a DataList), and a main image of the selected thumbnail. It also
has "Add Picture" and "Delete Picture" buttons.
"Add Picture" will add a new picture, while "Delete Picture" will remove
the currently selected picture. These are both ASP:ImageButtons, with the
functionality implemented in the OnClick events.

This control is then embedded in a page. This all works, with only 1
problem.

When I add a new picture it does not appear until I manually reload the
page. Conversely, when I delete a picture it leaves a blank picture in
place (the file itself has been deleted, so I get the missing image 'X'),
until I manually reload the page.

I'm an experienced programmer, but I'm new to ASP .NET, so please take
that into account ;-)

Regards,

RB.

CODE SNIPPETS:
' ASCX PAGE
<div id="dvToolbar" class="toolbar">
File:
<INPUT
id="MyFile"
type="file"
size="40"
name="MyFile"
RunAt="Server"
/>
<br>
Caption:
<asp:textbox id="txtCaption"
runat="server"
EnableViewState="False">
</asp:textbox>
<asp:imagebutton id="btnAddPicture"
Runat="server"
ImageUrl="\image\add_.gif"
AlternateText="Add new picture"
EnableViewState="False">
</asp:imagebutton>
<asp:imagebutton id="btnDeletePicture"
Runat="server"
ImageUrl="\image\del_.gif"
AlternateText="Remove current picture"
EnableViewState="False">
</asp:imagebutton>
<asp:imagebutton id="btnEditCaption"
Runat="server"
ImageUrl="\GEMs\image\Edit.gif"
AlternateText="Set caption of current picture"
EnableViewState="False">
</asp:imagebutton>
</div>
<div id="dvPhotos" runat="server">
<div id="dvThumbnails" class="thumbnails">
<asp:datalist id="dlPhotos"
RepeatDirection="Horizontal"
runat="server"
RepeatLayout="Flow"
Height="18px"
EnableViewState="False">
<ItemTemplate>
<asp:Image ID="Image1"
Runat=server ImageUrl='<%# "Thumbnail.aspx?filename=" &
Container.DataItem("photoFileName") & "&width=120" %>'
AlternateText='<%# Container.DataItem("photoDescription")%>'>
</asp:Image>
</ItemTemplate>
</asp:datalist>
</div>
<div id="dvMain" class="mainimage">
<asp:image id="imgMain"
runat="server"
EnableViewState="False">
</asp:image>
<br />
<div style="VISIBILITY:hidden">
<asp:TextBox id="txtHiddenPhotoId" Runat="server" />
</div>
</div>
</div>

' CODE BEHIND
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
' Bind thumbnail images to grid
Dim sr As SqlClient.SqlDataReader = myDev.GetDevPhotos(DevId)
If (sr.Read) Then
ShowPhotoControls(True)
Else
ShowPhotoControls(False)
End If
dlDevelopmentPhotos.DataSource = myDev.GetDevPhotos(DevId)
dlDevelopmentPhotos.DataBind()
End Sub

Private Sub ShowPhotoControls(ByVal bShow As Boolean)
'Hide the photos div block (dvPhotos) and the
'Delete button if required (because there are no
'photos available).
If bShow Then
dvPhotos.Attributes.Item("style") = ""
Else
dvPhotos.Attributes.Item("style") = "VISIBILITY:hidden"
End If
btnDeletePicture.Visible = bShow
End Sub

Private Sub btnDeletePicture_Click(ByVal sender As System.Object,
ByVal e As System.Web.UI.ImageClickEventArgs) Handles
btnDeletePicture.Click
'Code to remove picture from database
End Sub

Private Sub btnAddPicture_Click(ByVal sender As System.Object, ByVal e
As System.Web.UI.ImageClickEventArgs) Handles btnDeletePicture.Click
'Code to save uploaded picture.
'Code to insert photo into database.
End Sub


.



Relevant Pages

  • Re: Digital Image Stitching II
    ... Question on Hugin though, can it handle more than one row of photos, ... set control points between a picture and one other picture. ... for close-up panoramas. ...
    (rec.photo.digital)
  • Re: Digital Image Stitching II
    ... Question on Hugin though, can it handle more than one row of photos, ... set control points between a picture and one other picture. ... By the way, did you install autosift? ...
    (rec.photo.digital)
  • Re: Goth Weekend Photos (Originally Taken For The Whitby Gazette & Sexy Sunday Website)
    ... >>> photos that the photos might be offered for sale, ... to process those picture ie. that let someone else make money from them. ... > But in geneal, the photos are put up for free, and not for sale. ... on a charge of appallingly bad taste. ...
    (uk.people.gothic)
  • Re: photography documentaries
    ... Then you have to keep your photos of the internet. ... copy of your picture or they can't share such a copy with others. ... if people try to sell your picture or claim they ... without consulting the original photographer in advance about this, ...
    (rec.photo.digital)
  • Re: Graphics are moving when printed and fuzzy.
    ... I only print at 300 dpi and my photos are the same. ... > try to keep the picture in the same position with respect to its anchor. ... > suspect is that you are using JPEG pictures. ...
    (microsoft.public.mac.office.word)