Click here to Skip to main content
15,889,651 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi,

Below is my Method. I want to show the message once the data inserted into table.

C#
try
{
                for (int i = 0; i < Dt.Rows.Count; i++)
                {
                    DataRow row = Dt.Rows[i];
                    int columnCount = Dt.Columns.Count;
                    string[] columns = new string[columnCount];
                    for (int j = 0; j < columnCount; j++)
                    {
                        columns[j] = row[j].ToString();
                    }
                    SqlCommand cmd = new SqlCommand("#");
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("@ApplicationType", columns[0]));
                    cmd.Parameters.Add(new SqlParameter("@Title", columns[1]));
                    cmd.Parameters.Add(new SqlParameter("@FirstName", columns[2]));
                    cmd.Parameters.Add(new SqlParameter("@LastName", columns[3]));
                    cmd.Parameters.Add(new SqlParameter("@Gender", columns[4]));
                    DataSql dal = new DataSql();
                    object obj = dal.connectedMethod(cmd, DataSql.executemethods.ExecuteNonQuery);                    
                }
                System.Web.HttpContext.Current.Response.Write("<script language=\"javaScript\">" + "alert('All data's are uploaded into system!');" + "window.location.href='##';" + "<" + "/script>");
}



Please help me how to I show the message once all the data inserted into table.
Posted
Updated 12-Jul-15 17:57pm
v2
Comments
Afzaal Ahmad Zeeshan 12-Jul-15 23:58pm    
Are you using ajax? Because, it doesn't even matter whether you show the popup or not if you are sending HTTP requests and reloading the pages based on HTTP requests.
Suvendu Shekhar Giri 13-Jul-15 0:04am    
What '#' means in
SqlCommand cmd = new SqlCommand("#");
?
v2vinoth 13-Jul-15 0:22am    
# means page redirect - index.aspx
I want to show alert the data inserted into table

1 solution

If you want to show a popup, show a popup, not alert, which is hardly designed for real fully-fledged Web applications. This is done using window.open:
https://developer.mozilla.org/en-US/docs/Web/API/Window/open[^].

However, many users consider all pop-ups as evil, for some good reasons. Not only this is intrusive and inconvenient, but the user will try to avoid annoying advertizement pop-ups. For this purpose, pop-up blocking browser plug-ins can be used; and such plug-ins are fairly popular.

At the same time, you can easily mimic the modal behavior on the same page, which is more convenient and gives much better impression and user experience. For example, you can use jQuiery UI Dialog:
https://jqueryui.com/dialog[^].

Besides, there a many 3-rd party jQuery components ("plug-ins"), collectively referred to as modal popup, offering different visual effects (notably dimming of the window) and other features: http://bfy.tw/Vdm[^].

—SA
 
Share this answer
 
Comments
v2vinoth 13-Jul-15 0:28am    
I want to show alert when the data inserted into table.. If I got error means the alert is showing but the success it will not show any alert

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900