Reputation: 3279
I've created a simple captcha system in my assp.net web application, I use an ASPX page as ImageUrl of my captcha image, this ASPX file creates captcha image and returns it to be used as my image source. It works fine but I'm going to insert a Change Captcha button which I'd like to change my captcha WITHOUT REFRESH, I've used to methods with no success,
first I tried Ajax Update panel and inserted my change captcha button and my captcha image into it, my captcha didn't change (of course when I use a button outside of update panel to change captcha, it works fine but I have page refresh), this is my button click code:
protected void Button1_Click(object sender, EventArgs e)
{
imgCaptcha.ImageUrl = "CreateCaptcha.aspx?New=1";
}
then I used a Jquery Ajax call (web method) to call my CaptchaImage.ASPX file and use it as my image source, but again I had no luck! what is going wrong here? in both cases my CaptchaImage.ASPX file is never called! how can I change my captcha image without page refresh?
thanks
Upvotes: 0
Views: 2529
Reputation: 10694
$('#btnSearch').click(function () {
var src = //Url to image
$('#image').attr("src", src);
});
Above code changes source of image (#image) used b'coz image is the id for the imagebox.or whatever u using.
Upvotes: 1