Dear All,
I have one problem want all of you help me. I create web application that have page for insert, update ,delete button. but when I delete data I want have popup message box for confirm by using JavaScript. If they click Ok data will delete but when they click cancel data not delete. I try to find more code in website but not have solution. please help me do solve it.
Thank advance.
Mala
Loading
Satyapriya NayakPosted Feb 25, 2012, 10:42 PM
Try this...
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Insert_data_confirmation._Default" %>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace Insert_data_confirmation
{
public partial class _Default : System.Web.UI.Page
{
string strConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
string str;
SqlCommand com;
protected void btn_insert_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(strConnString);
con.Open();
com = new SqlCommand("insert into employee values(@name,@address,@sal)", con);
com.Parameters.AddWithValue("@name", txtname.Text);
com.Parameters.AddWithValue("@address", txtaddress.Text);
com.Parameters.AddWithValue("@sal", txtsal.Text);
com.ExecuteNonQuery();
com.Dispose();
con.Close();
Response.Write("Records successfully inserted");
clear();
}
void clear()
{
txtname.Text = "";
txtaddress.Text = "";
txtsal.Text = "";
}
}
}
Thanks
If this post helps you mark it as answer
Manath PathanaPosted Feb 25, 2012, 11:15 PM
Shen HengbinPosted Feb 25, 2012, 10:40 PM
Manath PathanaPosted Feb 25, 2012, 9:05 PM
Satyapriya NayakPosted Feb 25, 2012, 1:04 PM
Try this...
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Confirm_delete_button._Default" %>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace Confirm_delete_button
{
public partial class _Default : System.Web.UI.Page
{
protected void Button1_Click(object sender, EventArgs e)
{
Button1.Attributes.Add("onclick", "return ConfirmOnDelete();");
}
}
}
Thanks