Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i want to dispaly message box using java script on clicked on button that "Data Saved Sucessfully".
Regards
Manohar Khilare
Posted
Comments
Vani Kulkarni 24-Jan-13 7:51am    
ok, so what is the question?

Hello freind,

if you want to show message after finishing your work from code behind then use this syntax at the end of your buttong click event last line.

C#
protected void btnJavasctiptAlert_Click(object sender, EventArgs e)
{
     //other work code here
     //like insert data code goes here
     ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "anything", "alert('Data Saved Sucessfully');", true);
}


or just simply want to add javascript mesage from design side then use like this...

ASP.NET
<asp:button id="btn" runat="server" text="Javascript Click" onclientclick="javascript:alert('Data Saved Sucessfully');" xmlns:asp="#unknown" />
 
Share this answer
 
Comments
ridoy 24-Jan-13 13:35pm    
+5
A pretty vague question. But still here's I think what you can do.

I'm pretty sure you want to show this message after actually saving the data...:) If you are saving the data asynchronously using jquery or .Net Page methods...you can write your code at the end of success method.

You can use jquery dialog for showing the message. It's pretty easy to implement also.

<asp:button id="btn" runat="server" text="Javascript Click" onclientclick="javascript:SaveData(a);" xmlns:asp="#unknown" />


<script>

function SaveData(a){
if (typeof a !== "undefined"){
   PageMethods.SaveData(a,savesuccess,savefailed);//you can use the jQuery syntax also here if you are using webservice to save the data.
}
}
function savesuccess(){
    alert('Data Saved');
}
function savefailed(){
   alert('Save Failed');
}
</script>


If this is not what you are looking perhaps changing the question would help. :)
 
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