Reputation: 694
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.
Upvotes: 2
Views: 284
Reputation: 5670
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.
Upvotes: 3