Archive

Posts Tagged ‘postback’

Preserving values of password fields after postback

August 18th, 2009

You have created your sign up form with full power of AJAX but when you do your trick to check for username availability via AJAX, it seems that passwords fields are reset. You can overcome this situation by setting up passwords filed values each time you make a postback.

1
txtPassword.Attributes.Add("value", txtPassword.Text);

That should do the trick!

ASP.Net, Programming , , ,

How to disable button that causes postback in ASP.net

April 30th, 2009

You can disable a button on the client side to prevent multiple clicks by just adding an onClick function that runs on client side. You should check if page has a client side validation script and it passes first. If so, you just disable the button and call postback event.

Here is an example for the button named “btnAddcustomer”. Just paste it into Page_Load.

1
2
Dim strDisable As String = "if (typeof(Page_ClientValidate) == 'function') {if (Page_ClientValidate() == false) { return false; }} this.value = 'Please wait...'; this.disabled = true; " & ClientScript.GetPostBackEventReference(btnAddCustomer, "")
btnAddCustomer.Attributes.Add("onclick", strDisable)

ASP.Net, Programming , , ,