Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
insert code as follows;
 
<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 26-Dec-12 18:54pm
Edited 26-Dec-12 18:55pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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
$("#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");
		}
	});
});
 

 

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);
}
  Permalink  
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

You can try MessageBox[^]
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 373
1 Sergey Alexandrovich Kryukov 197
2 Richard Deeming 160
3 PhilLenoir 120
4 RyanDev 115
0 Sergey Alexandrovich Kryukov 6,405
1 OriginalGriff 5,798
2 CPallini 2,473
3 Richard MacCutchan 1,647
4 Abhinav S 1,530


Advertise | Privacy | Mobile
Web04 | 2.8.140821.2 | Last Updated 27 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100