Link to home
Start Free TrialLog in
Avatar of sdugar
sdugar

asked on

Change Image Inside UpdatePanel Dynamically

Hi Friends,

I'm generating an image (graph.jpg) runtime and saving it to the server and displaying it in a image control by setting its ImageUrl property. The Image control is inside an UpdatePanel.

The problem is that,

Image is displaying (with change) fine when EnableViewState=False, but not showing any changes when EnableViewState=True.

Please tell me the reason and provide a solution.


<asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode="Conditional" >
 <ContentTemplate>
 
..................
..................
 
<asp:LinkButton ID="linkGraph" CssClass="submit" Width="150" runat="server" Text="CREATE GRAPH" OnClick="DisplayGraph"></asp:LinkButton>
 
<asp:Image ID="imgGraph" runat="server" ImageUrl="~/Images/graph.jpg" />
 
 
</ContentTemplate>
<Triggers>
 <asp:AsyncPostBackTrigger ControlID="linkGraph" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
 
 
 
protected void DisplayGraph(object sender, EventArgs e)
{
.................
.................
Graph.GraphToFile(Server.MapPath(hostName + "Images/" + "graph.jpg"));
 
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of jotero25
jotero25

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sdugar
sdugar

ASKER

Thanks a lot.
Avatar of sdugar

ASKER

Hi jotero25,

Thanks for your valuable reply.

Your suggesion is helpfull and now it is working properly.

One more thing - Can i solve it by clearing caching image?
Hi sdugar,

Clearing the caching image would probably work, but that is not a good solution since it is better to preserve the data that never change in cache to increase the solution performance.