"Nathan Sokalski" <> wrote in
news::
> Are there any ways to create a Button that does not do a postback?
Use an HtmlControl instead of a server control and make sure you do not
set runat="server" is your best option. I am not sure why you do not
want to do this, as it is the best option when you do not want a
postback.
If absolutely MUST neuter an ASP.NET server control button, then do
something like:
<asp:Button ID="ButtonName" runat="server" Text="Click for JavaScript"
OnClientClick="return functionName()" />
You then have to ensure the function returns false:
<script type="text/javascript" language=javascript>
function functionName() {
alert('Look ma, no server script!');
return false;
}
</script>
The return false effectively neuters the button.
Another option is to subclass the button server control and neuter it.
It will end up with nearly identical code to the HtmlControl, however.
But it will retain some of the "goodness" of an button server control.
Peace and Grace,
--
Gregory A. Beamer (MVP)
Twitter: @gbworld
Blog:
http://gregorybeamer.spaces.live.com
*******************************************
| Think outside the box! |
*******************************************