Javascript Alert Popup on ItemUpdated

Posted on 2009-07-02
Medium Priority
Last Modified: 2012-05-07
Need to have an alert fire after a formview updates.  Here is the code I have which is not working.
script language='javascript' type='text/javascript'> 
function confirmSelection() 
if (Page_IsValid) 
return confirm('Are you sure you want to delete this record?'); 
return false; 
2. In your Page_Load event handler, add this line:
Me.fvLog.Attributes.Add("ItemUpdated", "return confirmSave()")

Open in new window

Question by:cadwal01
  • 2
  • 2

Author Comment

ID: 24766206
Slight correction, I do have both the function names the same in my code.
LVL 41

Expert Comment

ID: 24766563
So say you have a button Update in your FormView EditItemTemplate to update then try this:

<asp:Button ID="btnUpdate" CommandName="Update" runat="server" OnClientClick="return confirm('Are you certain you want to update?');" Text="Update" />

Author Comment

ID: 24767017
I want to give the user confirmation that the record has been saved/added.  They want a visual cue fro some reason.  So this would be after the ItemUpdated event.  Perhaps a hidden button with tthis code attached?
LVL 41

Accepted Solution

guru_sami earned 2000 total points
ID: 24768004
try something like this:
protected void FormView1_ItemUpdated(object sender, FormViewUpdatedEventArgs e)
        System.Text.StringBuilder script = new System.Text.StringBuilder();
        script.Append("<script language='javascript'>");
        script.Append("alert('Item Updated');");
  Type t = this.GetType();
  if (!Page.ClientScript.IsStartupScriptRegistered(t, "AlertScript"))
      Page.ClientScript.RegisterStartupScript(t, "AlertScript", script.ToString());

For more info check this:

Featured Post

A proven path to a career in data science

At Springboard, we know how to get you a job in data science. With Springboard’s Data Science Career Track, you’ll master data science  with a curriculum built by industry experts. You’ll work on real projects, and get 1-on-1 mentorship from a data scientist.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

This shares a stored procedure to retrieve permissions for a given user on the current database or across all databases on a server.
In this article, we will see two different methods to recover deleted data. The first option will be using the transaction log to identify the operation and restore it in a specified section of the transaction log. The second option is simpler and c…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

607 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question