Gihan Lasita
Gihan Lasita

Reputation: 3053

how to prevent refresh on asp.net c# web page button?

how to prevent refresh on asp.net c# web page button?

protected void Button1_Click(object sender, EventArgs e)
{

}

Regards

Upvotes: 0

Views: 4418

Answers (3)

you can do it by creating a cookie inside your Button1_Click method. The first instruction within this method should check if that cookie exists or has not expired. In case itdoesn't exist or it expired, the follow line will create or update the cookie. In case the cookie exists, return; Sorry i cant give code cause im using my mobile.

Upvotes: 0

Ali Foroughi
Ali Foroughi

Reputation: 4619

you must use this way :

<asp:button ID="btn" runat="server" Text="Button" onClientclick="btn_Click(event);">     </asp:button>
<script>

function btn_Click (e)
{

    if(//Check somthing)
          e.preventDefault();

}

</script>

Upvotes: 1

Kinexus
Kinexus

Reputation: 12904

Short answer, you can't.

However, using methods such as ajax, you can hide the appearance of the postback.

Upvotes: 0

Related Questions