I have an ASP.NET linkbutton control on my form. I would like to use it for javascript on the client side and prevent it from posting back to the server. (I'd like to use the linkbutton control so I can skin it and disable it in some cases, so a straight up tag is not preferred).
How do I prevent it from posting back to the server?
No one seems to be doing it like this:
This seems to be the only way that works.
Just set href="#"
I think you should investigate using a HyperLink control. It's a server-side control (so you can manipulate visibility and such from code), but it omits a regular ol' anchor tag and doesn't cause a postback.
Just been through this before few minutes, the correct way to do it is use
OnClientClick
Return False()
as the following example line of code:
Just copied that line from my working code.
Why not use an empty ajax update panel and wire the linkbutton's click event to it? This way only the update panel will get updated, thus avoiding a postback and allowing you to run your javascript
use html link instead of asp link and you can use label in between html link for server side control