Apr 14
2009

Im allgemeinen verursacht ein ASP.NET LinkButton einen PostBack. Vereinzelt ist es jedoch notwendig, trotz einer Aktion auf dem Button den PostBack zu unterdrücken.  Mit einem simplen "return false;" im clientseitigen Eventhandler läßt sich das PostBack unterdrücken:

<script language="javascript" type="text/javascript">
    function alertMessage()
    {
        alert('Ich bin ein LinkButton, der keinen Postback verursacht!');
        return false;
    }
</script>

<asp:Button
    ID="btnTestAlert"
    runat="server"
    Text="abschicken"
    ToolTip="Ich bin ein ToolTip zum Button btnTestAlert"
    OnClientClick="return alertMessage();" />

 

Tags:

Related posts

Comments

Sven

Posted on Monday, 20 April 2009 23:01

Hast du eigentlich mal mit jQuery rumgespielt? Ich bin da mittlerweile ja sehr begeistert von. Auch wenn es seine Tücken hat.

Roland

Posted on Tuesday, 21 April 2009 08:39

Hi Sven, mit jQuery habe ich mich bisher noch nicht befaßt. Das wäre tatsächlich mal eine Recherche wert. Danke für den Tipp.

Sven

Posted on Thursday, 23 April 2009 21:09

Immer wieder gerne. Schnucki ;)

natural

Posted on Wednesday, 27 May 2009 14:09

Hello, tell me please on your blog I can find only German articles or I can find also articles in English?

rolo

Posted on Friday, 29 May 2009 07:48

Sorry but currently there is only the headline in english. In the future the articles will be in english too.

Nick

Posted on Wednesday, 3 June 2009 16:13

Thanks for a good script!

personal loans

Posted on Tuesday, 3 November 2009 22:00

Just try to smile for about 2-3 mins then you can get back to work

online personal loans

Posted on Tuesday, 3 November 2009 22:59

Like your writing! Still you can do some things to improve it.

Comments are closed