asp.net - Trouble using response.redirect -


hi , sorry poor english.

i have asp.net + vb.net application , here example of code illustrating problem :

first have default.aspx page 2 buttons, "valid" , "redirect"

 protected sub butvalid_click(sender object, e eventargs) handles butvalid.click      if (file.exists(server.mappath("log.txt")))         dim lines() string = io.file.readalllines(server.mappath("log.txt"))          dim tmp integer = convert.toint32(lines(lines.length - 1))         tmp = tmp + 1          file.appendalltext(server.mappath("log.txt"), environment.newline & tmp.tostring)     else         file.writealltext(server.mappath("log.txt"), "1")     end if  end sub  protected sub redirect_click(sender object, e eventargs) handles redirect.click     response.redirect("accueil.aspx") end sub 

valid button write txt file , redirect redirecting ...

here page_load code of accueil.aspx :

threading.thread.sleep(3000) response.redirect("default.aspx") 

the problem when click on redirect button in default.aspx page, valid button remains accessible , user can click on valid button.

how can disable valid button after redirect click ?

thanks in advance.

place in page_onload handler , fire @ each postback make sure bound. disable button on client side, , when page load fires again after click , response server done, button enabled again.

redirect.attributes.add("onclick", "javascript:"       + butvalid.clientid + ".disabled=true;"       + page.clientscript.getpostbackeventreference(redirect, null));     

Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -