Click here to Skip to main content
15,893,622 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
insert code as follows;

C#
<protected void="" eventargs="" mode="hold" />    {
Sql = "insert into BirthDayWish values('" + txt_name.Text + "','" + FromDate.SelectedDateValue.ToString() + "','" + txt_mobile.Text + "','" + Todate.SelectedDateValue.ToString() + "','" + txt_Email.Text + "','A')";
            
            try
            {
                SCon.Error = "";
                SCon.ExecSql(Sql);
                if (SCon.Error.ToString() != "")
                {
                    Label6.Text = Session["Error"].ToString();
                    
                }
                
                SCon.Con.Close();
                
      }
        catch (Exception Ex1)
        {
            Response.Write(Ex1);
            
        }
    }


after click the insert button i want to show the message "Records Inserted Successfully";

how to do in asp.net with csharp. please help me.
Posted
Updated 26-Dec-12 18:55pm
v2

Delete all this code and start again. I can delete your entire data base with a SQL injection attack. Then I recommend using ASP.NET MVC, but either way, I recommend using jquery and AJAX to do the insert and show the message. If you want your web site to look like 1996, then you can put a literal control on your page and populate it with script to show a popup message in javascript.
 
Share this answer
 
This code snippet is geared towards MVC 3 but is easily adaptable for whatever you are doing.


//Jquery using JSON to submit to the controller and its values
//Will Controller action will return either SUCCESS or FAILED and based on this
//you can display whatever message you'd like using a hidden div or div with no text
JavaScript
$("#IdOfElementOnPage").live("click", function(){
	$.getJSON("@Url.Action("ActionName", "ControllerName")", {
		val1: $("#TextBox").val(),
		val2: $("#TextBox2").val()
	}, function (data) {
		if(data.returnmsg == "SUCCESS")
		{
			$("#DivWithNoText").html("Record Inserted Successfully");
		}
		else
		{
			$("#DivWithNoText").html("Something Blew Up");
		}
	});
});





C#
public JsonResult ActionName(string val1, string val2)
{
	string resultmsg = null;
	
        //Do Whatever processing/inserting/error checking inside here and pass back 
        //a return result message so that way you know if it passed or failed
	if(x = 1)
	{
		resultmsg = "SUCCESS";
	}
	else
	{
		resultmsg = "FAILED";
	}
	
	return Json(returnmsg = resultmsg, JsonRequestBehavior.AllowGet);
}
 
Share this answer
 
v3
You can try MessageBox[^]
 
Share this answer
 

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