|
Forums » .NET » ASP.NET »
|
How to prevent showing alert messages when page is refreshing or reloading? |
Posted Date: 16 Jul 2012 Posted By:: GiRi $ Member Level: Silver Member Rank: 362 Points: 3
Responses:
3
|
In my web page having edit and cancel button .if we click edit button means it provide already user information to update,after finish the edit operation it shows the alert message that updated successfull..if i click refresh f5 continuously means again it show the alert message.how do prevent this????
|
Responses
|
#680588 Author: Ajatshatru Upadhyay Member Level: Gold Member Rank: 20 Date: 16/Jul/2012 Rating:  Points: 2 | Hi,
It seems that you put the alert message statement in page load. Put the code in button click event. If this is not the case, please provide some more detail with code.
Hope it'll help you. Regards Ajatshatru
| #680620 Author: Anil Kumar Pandey Member Level: Platinum Member Rank: 1 Date: 17/Jul/2012 Rating:  Points: 2 | Please put the alert message binding in the ASPX page level only.
if at all you are using it with the code behind then put the code under the !PAGE.ISPOSTBACK()
Thanks & Regards Anil Kumar Pandey Microsoft MVP, DNS MVM
| #680983 Author: GiRi $ Member Level: Silver Member Rank: 362 Date: 19/Jul/2012 Rating:  Points: 1 | <asp:Button ID="btnSave" runat="server" onclick="btnSave_Click" Text="Button" />
protected void Page_PreRender(object sender, EventArgs e)
{
ViewState["IsPageRefreshed"] = Session["IsPageRefreshed"];
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Session["IsPageRefreshed"] = Server.UrlDecode(System.DateTime.Now.ToString());
}
}
protected void btnSave_Click(object sender, EventArgs e)
{
if (Session["IsPageRefreshed"].ToString() == ViewState["IsPageRefreshed"].ToString())
{
Session["IsPageRefreshed"] = Server.UrlDecode(System.DateTime.Now.ToString());
ScriptManager.RegisterClientScriptBlock(this, this.Page.GetType(), "abc", "alert('Button clicked')", true);
}
}
this is the answer
|
|
| Post Reply |
|
|
|
 | | This thread is locked for new responses. Please post your comments and questions as a separate thread. If required, refer to the URL of this page in your new post. |
|
|
|
|
 Follow us on Twitter: https://twitter.com/dotnetspider
|
|