• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2967
  • Last Modified:

Asp.Net Linkbutton force it to not postback

Is there anyway that I can make a linkbutton not postback but instead run a javascript?
0
johnywhite
Asked:
johnywhite
1 Solution
 
Sam_JayanderCommented:
Hi,
Try adding a "return false;" as the last line in the javascript. It works for me.

eg:
LinkButton1.Attributes.Add("onClick","javascript:alert('Hello World!');return false;");

HTH,
--Sam.
0
 
Rajulkumar PatelCommented:
Hi,

The only one way is add a attribute to linkbutton in page load event.


LinkButton1.Attributes.Add("onClick","JavaScript:return false;");


Thanks
0
 
RejojohnyCommented:
mrrajpatel, how is this different from what Sam has suggested above?

johnywhite, pls close this question if its been answered .. it saves time for people like us who are browsing the open questions ..

Rejo
0
 
johnywhiteAuthor Commented:
I haven't had a chance to test it but I assume it works.
0
 
gtzpowerCommented:
Worked fine for me.  Thanks!
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now