开发者

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 redir开发者_JAVA技巧ecting another page it should display message like "Your data has been saved successfully". What should i do? Asp.net c# Thsnk you.


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


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


 <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>


Use Below :

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜