abc
abc

Reputation: 57

How to display particular message like alert message in asp.net3.5 c#

i have one form after clicking save button form redirecting to another page, but before redirecting another page it should display message like "Your data has been saved successfully". What should i do? Asp.net c# Thsnk you.

Upvotes: 0

Views: 3476

Answers (4)

Hassan Mokdad
Hassan Mokdad

Reputation: 5892

say your button id was btnTest, use this code in the Page_Loadevent of your aspx Code behind Page:

btnTest.Attributes.Add("onClick", "return ShowSuccessMessage();");

and in your html page, use the following javascript function:

function ShowSuccessMessage()
{
alert("Your data has been saved successfully");
return true;
}

This way your button won't trigger a post back event till the alert message is shown

Upvotes: 1

Saurabh
Saurabh

Reputation: 5727

Use Below :

ClientScript.RegisterStartupScript(this.GetType(), "popmsg1", "<script language=javascript>alert('Your data has been saved successfully.'); location.href='page.aspx';</script>");

Upvotes: 0

user339160
user339160

Reputation:

 <asp:button id="btnSave" Text="Save"
       onclientclick="ShowMessage()"
       runat="server" onclick="btnSave_Click" />

<script type="javascript">

function ShowMessage()
{
  document.window.alert("Your data has been saved successfully.");
}

</script>

Upvotes: 0

Baz1nga
Baz1nga

Reputation: 15579

see the confirm box here: http://www.w3schools.com/JS/js_popup.asp

Upvotes: 0

Related Questions