Alexandre
Alexandre

Reputation: 13308

Force refresh image in update panel

I have a button and an image in update panel. How do I force the image refresh by clicking on the button?

update

    <b>Enter the code</b>
     <asp:UpdatePanel runat="server">
        <ContentTemplate>
          <uc:TextBox ID="txtCaptcha" runat="server" />
          <asp:Button ID="btnRefreshCaptcha" runat="server" Text="Refresh the code" CausesValidation="false" onclick="btnRefreshCaptcha_Click" />
          </ContentTemplate>
          <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnRefreshCaptcha" EventName="Click" />
          </Triggers>
    </asp:UpdatePanel>

Upvotes: 3

Views: 6865

Answers (3)

karthick
karthick

Reputation: 11

i used the above code but it shows the script problem in dropdown list what i gave it in master page and call them as a class files in every pages.After using the above code in my coding and i refresh the captcha it shows the overload of dropdownlist in my page and refreshment of captcha works only once after tis problem occurs i cant to refresh the captcha image in my page.

Upvotes: 1

DanNsk
DanNsk

Reputation: 900

Add random value parameter to the end of your image url and change that on each update

kind of ImageUrl = baseUrl + "?" + new Random().Next()

Upvotes: 8

Ahmad
Ahmad

Reputation: 12707

Did you try

Sub btnRefresh_Click() Handles btnRefresh.Click

    Me.Image.ImageUrl = "path to your image file"

End Sub

Upvotes: 1

Related Questions