...

View Full Version : Postback and ClientClick



alinulms
12-28-2011, 01:11 PM
Hej all,

I have this issue.


<asp:Button PostBackUrl="www.google.com" runat="server" OnClientClick="Validate();" />


Problem is that i get to the postback page before the validation is finished. In fact my validation is saving something in the database and there is my problem.

Anyone has any suggestions?

DanInMa
12-28-2011, 01:29 PM
this is probably a .net issue and not a JavaScript issue.

alinulms
12-28-2011, 01:36 PM
hmm... i will look at the problem from that side also. 10x

I did. if i run with firebug or debug in VS then it actually saves. So saving in DB is ok every time i am debugging.

alinulms
12-29-2011, 09:28 AM
Still cannot fix it. Can anybody suggest anything of any kind? Thank you

Philip M
12-30-2011, 08:35 AM
Hej all,

I have this issue.


<asp:Button PostBackUrl="www.google.com" runat="server" OnClientClick="Validate();" />


Problem is that i get to the postback page before the validation is finished. In fact my validation is saving something in the database and there is my problem.

Anyone has any suggestions?


OnClientClick="return Validate()";

All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

alykins
12-30-2011, 06:11 PM
because your button fires a postback and then you have it redirecting- the js probably happens but you never see it bc you are long gone redirected by the time it does anything. why are you using js to validate? you can validate server side if running asp.net and if validation happens then response redirect instead of postback...


<asp:Button runat="server" ID="btn" OnClick="btn_Click" />
..............
btn_Click(object sender, EventArgs e){
// get all you validation fields
// validate them based on parameters you define
// if (validate){
//*assuming save something to a DB?
//Response.Redirect("http://www.google.com");
//else
//do whatever it is you want to do if validation fails
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum