简体   繁体   中英

how to prevent web page refreshing

I have a "CaptchaControl" in a webusercontrol, when i click refresh link for the captcha code, the page refresh too. how can i prevent it?

<cc:CaptchaControl ID="captcha" CssClass="toppading" runat="server"  CharCount="5"  ImageUrl="~/images/CapchaImage.jpg" /> 

   <asp:LinkButton CssClass="leftpading" id="btnReset" runat="server" Text="Refresh" resourcekey="lblrefresh" OnClick="btnReset_Click" ></asp:LinkButton>


protected void btnReset_Click(object sender, System.EventArgs e)
{
    captcha.Refresh();
}

i've heard something about ajax, but i'm green in ajax.

Ajax is the best solution for this problem.ajax will send data to your server with out making a post back in your browser. Just add an ajax update-panel in your form(you can find this in your Toolbox under the tab Ajax extensions) and put your user-control inside it.And don't forget to add a script-manager in the beginning of your form.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM