For Programmers: Free Programming Magazines  


Home > Archive > ASP .NET > November 2006 > Postback thru javascript









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Postback thru javascript
krallabandi@gmail.com

2006-11-29, 7:08 pm

I have asp button control on the page. I need to check some condition
before I postback the page.

Actually it is posting back for both true, false conditions.

I want to postback only if the condition is true. otherwise I want to
stay on the same page.

Note: I have many other asp buttons controls should postback. I need to
check for the condition only for one asp button control.

Thanks.

Eliyahu Goldin

2006-11-29, 7:08 pm

Handle the client-side onclick event. Make the javascript event handler to
return true if you want to proceed with the postback or false otherwise:

myButton.Attributes["onclick"] = "return myJavascriptHandler()";

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


<krallabandi@gmail.com> wrote in message
news:1164818469.611658.270500@16g2000cwy.googlegroups.com...
>I have asp button control on the page. I need to check some condition
> before I postback the page.
>
> Actually it is posting back for both true, false conditions.
>
> I want to postback only if the condition is true. otherwise I want to
> stay on the same page.
>
> Note: I have many other asp buttons controls should postback. I need to
> check for the condition only for one asp button control.
>
> Thanks.
>



bruce barker

2006-11-30, 7:04 pm

the asp:button works in two ways.

1) standard html submit button. to cancel your client code returns false on
the onclick:

<input type=submit onclick='return postbackcheck();'>

2) the input is render with a onclick call to '__dopostback', usually
checking validation. here you need to duplicate the code to cancel.

the supported approach is to write a custom validator, and turn on causes
vaidation on your button.

-- bruce (sqlwork.com)

<krallabandi@gmail.com> wrote in message
news:1164818469.611658.270500@16g2000cwy.googlegroups.com...
>I have asp button control on the page. I need to check some condition
> before I postback the page.
>
> Actually it is posting back for both true, false conditions.
>
> I want to postback only if the condition is true. otherwise I want to
> stay on the same page.
>
> Note: I have many other asp buttons controls should postback. I need to
> check for the condition only for one asp button control.
>
> Thanks.
>


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com