UpdatePanel only updates once

S

Scott M

I have a listview that contains thumbnails of images. When one is
clicked it should show the full size image below in an asp:image
control. The first time a thumbnail is clicked it works. The second
time it will not. I tried updating the UpdatePanel manually had got the
same results.

here is the datalist and updatepanel from my .aspx:

<asp:DataList BackColor="Black" ID="DataList1"
runat="server" CellPadding="10" RepeatColumns="3"
RepeatDirection="Vertical">
<ItemTemplate>
<asp:ImageButton ID="meterImage" runat="server"
OnCommand="meterImage_ClickCommand"
CommandArgument='<%#
DataBinder.Eval(Container.DataItem,"picture") %>'
ImageUrl='<%#
DataBinder.Eval(Container.DataItem,"picture") %>' />
</ItemTemplate>
</asp:DataList>

<asp:UpdatePanel ID="meterUpdatePanel" runat="server"
UpdateMode="Conditional">
<ContentTemplate>
<div id="meterpicDIV" style="margin-top: 5px;">
<asp:Image ID="imgBigMeter" runat="server"
ImageUrl="" />
</div>
</ContentTemplate>
</asp:UpdatePanel>


and here is the method in my code behind that changes the image:

protected void meterImage_ClickCommand(object sender,
CommandEventArgs e)
{
string thumburl = e.CommandArgument as string;
string meterurl = "images/meters/" + Path.GetFileName(thumburl);
imgBigMeter.ImageUrl = meterurl;
meterUpdatePanel.Update();
}

Any thoughts? Its been frustrating me all day.
 
B

bruce barker

its unclear why you are using an updatepanel. the list is doing a full
postback, so there is no advantage. anyway check the logic that mak the
big url, filepath will not work with forward slashes.

-- bruce (sqlwork.com)
 
S

Scott M

I put a break point in my code behind, where the new image is assigned.
It hits there and I see that the variable storing the url has changed.
But when it goes to assign the new image it jumps into several (about 5)
Microsoft defined .cs files. I can't follow what's going on, but it
ends up not assigning the new image.

The filepath works find the the forward slashes. If I remove the update
panel the whole thing works perfectly. Except that it refreshes the
whole page every time you click on a new thumbnail. I don't want the
whole page to refresh, that's why I'm trying to use an updatepanel.
 
S

Scott M

I'm getting somewhere. I added a OnItemBound event to my datalist that
does the following:

protected void DataList_OnItemBound(object sender,
DataListItemEventArgs e)
{
ImageButton ib = e.Item.FindControl("meterImage") as
ImageButton;
ScriptManager1.RegisterAsyncPostBackControl(ib);

}


The first time a thumbnail is clicked the fullsize image loads without a
full page refresh. The second time a thumbnail is clicked the whole
page is refreshed. Why doesn't it work on subsequent clicks?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top