how to show sucess after insert a value
how to show sucess after insert a value without using label (using java script)
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
SenthilkumarPosted May 17, 2012, 4:04 AM
If you want to show from the client side then,
window.alert('Saved successfully');
Or if you want to do it from the asp.net server side then,
Satyapriya NayakPosted May 17, 2012, 4:15 AM
Try this...
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Insert_success_javascript._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_success_javascript
{
public partial class _Default : System.Web.UI.Page
{
string strConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
string str;
SqlCommand com;
protected void Page_Load(object sender, EventArgs e)
{
}
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);
int result = com.ExecuteNonQuery();
if (result == 1)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowSuccess", "javascript:Display('" + txtname.Text + "')", true);
}
com.Dispose();
con.Close();
clear();
}
void clear()
{
txtname.Text = "";
txtaddress.Text = "";
txtsal.Text = "";
}
}
}
Thanks
If this post helps you mark it as answer