Home All Groups Group Topic Archive Search About

System.Web.UI.WebControls.Image control not refreshing

Author
7 Mar 2006 9:23 AM
John Keers
Can anyone tell me why, when I set an Image control ImageURL at runtime (on
the server) the control is not refreshed on the returned web page. (client
side)

I am using a callback to the server with the RaiseCallbackEvent method which
is receiving an eventArgument which is the url of the image that I want to
display. Within this method I am setting the ImageURL of the Image component
and forcing (explicit call) to:

Page_Load(this, new EventArgs());
I have a feeling that my approach is not working because I am forcing a call
back to the server and if so I would like to know how I can update and image
control at runtime.

Thanks in advance

Author
8 Mar 2006 2:28 AM
Steven Cheng[MSFT]
Hi John,

Welcome to the ASPNET newsgroup.

From your description, you have used some Image controls in your ASP.NET
2.0 web page. Also, you configure the page to use client script callback to
execute some functions on server-sdie without postback. In the callback's
server-side function, you can the Image control's Url , however you found
the image control(html element at clientside) does not get updated, correct?

Based on my understanding, the ASP.NET 2.0 script callback functionality
only address executing some code logic at server-side and return some
results through string representation. For control structure or properties,
we could not use the script callback to update them because the script
callback request differs from a normal postback request, there won't have
the same control collection processing and rendering steps.  As for your
scenario, you want to change the image control's URL, I think you can
consider use client-side script code to change the html img element's src
attribute, this can make the image be refreshed immediatlely. For example:

<asp:Image ID="imgDynamic" runat="server" /><br />

            <input type="text" id="txtImage" />
            <input type="button" value="change"
onclick="document.getElementById('imgDynamic').src =
document.getElementById('txtImage').value;" />


Hope this helps.

regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)