LinkButton & Postback

E

Eric

I have a linkbutton on a form that executes a script, it works fine except
that it posts back to the calling form first. Is there a way to prevent
this? I tried setting the PostBackURL property to the form the script
launches but that resulted in some strange behavior.

TIA
 
A

Alex Meleta

Hi Eric,

E.g. you can use this linkbutton .Attributes.Add("onclick", "return false")
if you just need to run script in OnClientClick and prevent postback.

Regards, Alex
[TechBlog] http://devkids.blogspot.com

E> I have a linkbutton on a form that executes a script, it works fine
E> except that it posts back to the calling form first. Is there a way
E> to prevent this? I tried setting the PostBackURL property to the
E> form the script launches but that resulted in some strange behavior.
E>
E> TIA
E>
 
B

bruce barker

a LinkButton is an anchor with javascript added to do a postback. if you
don't want to do a postback, don't use a link button, just use an anchor (or
HyperLink). if you just want to call a javascript routine from an anchor, the
usual trick is:

<a href="#" onclick="myfunction(this);return false;" >Click me</a>
or
<a href="javascript:myfunction(this);" >Click me</a>

note: some installs of IE fail to honor return false from an event, and must
include code to cancel event bubbling.

-- bruce (sqlwork.com)
 
C

coolit 2011

Great !!!!
it works.

thank's :)
I have a linkbutton on a form that executes a script, it works fine except
that it posts back to the calling form first. Is there a way to prevent
this? I tried setting the PostBackURL property to the form the script
launches but that resulted in some strange behavior.

TIA
On Tuesday, May 13, 2008 11:55 AM Mark Rae [MVP] wrote:
Do you actually require a round-trip to the server, or do you just need to
go to another page...?
On Tuesday, May 13, 2008 11:39 PM Alex Meleta wrote:
Hi Eric,

E.g. you can use this linkbutton .Attributes.Add("onclick", "return false")
if you just need to run script in OnClientClick and prevent postback.

Regards, Alex
[TechBlog] http://devkids.blogspot.com

E> I have a linkbutton on a form that executes a script, it works fine
E> except that it posts back to the calling form first. Is there a way
E> to prevent this? I tried setting the PostBackURL property to the
E> form the script launches but that resulted in some strange behavior.
E>
E> TIA
E>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top