Buttons without PostBack

  • Thread starter Thread starter Urs Vogel
  • Start date Start date
U

Urs Vogel

Hi

Is there a way to prevent an ASP-Button from performing a PostBack? I'ld
rather have a script controlling this behaviour.

Thanks, Urs
 
Hi,

The following will prevent the postback:

[C#]
button1.Attributes["onclick"] = "javascript:SomeFunction();return false;";
[VB]
button1.Attributes("onclick") = "javascript:SomeFunction();return false;"

The client-side function specified will get executed and there will be no
postback.

Greetings
Martin
 
Thanks. Sure, could have had the same idea myself, sorry for bothering ..
Martin Dechev said:
Hi,

The following will prevent the postback:

[C#]
button1.Attributes["onclick"] = "javascript:SomeFunction();return false;";
[VB]
button1.Attributes("onclick") = "javascript:SomeFunction();return false;"

The client-side function specified will get executed and there will be no
postback.

Greetings
Martin
Urs Vogel said:
Hi

Is there a way to prevent an ASP-Button from performing a PostBack? I'ld
rather have a script controlling this behaviour.

Thanks, Urs
 
Hi,
Could you please give the sample code which I can copy/past into my test
project?

Thanks.

william


Urs Vogel said:
Thanks. Sure, could have had the same idea myself, sorry for bothering ..
Martin Dechev said:
Hi,

The following will prevent the postback:

[C#]
button1.Attributes["onclick"] = "javascript:SomeFunction();return false;";
[VB]
button1.Attributes("onclick") = "javascript:SomeFunction();return false;"

The client-side function specified will get executed and there will be no
postback.

Greetings
Martin
Urs Vogel said:
Hi

Is there a way to prevent an ASP-Button from performing a PostBack? I'ld
rather have a script controlling this behaviour.

Thanks, Urs
 
Back
Top