Click here to Skip to main content
15,888,341 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I used below code for display message after data save on submit button its working fine but sometime not show message please help me in this....
C#
string msg = "Data saved successfully .";
 ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('" + msg + "');window.location='Home.aspx';", true);
Posted
Comments
[no name] 14-Sep-12 5:52am    
use this code it may solve your problem



<pre lang="text">



<%@ Page Language="C#" AutoEventWireup="true" CodeFile="disablingcopypastefeatureintextbox.aspx.cs" Inherits="disablingcopypastefeatureintextbox" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>

<script type="text/javascript">

function data()
{


if (document.getElementById('TextBox1').value != "" && document.getElementById('TextBox1').value != null) {


alert("data is submited ")


}
else {



alert("data is not submited ")

}

}

</script>
</head>
<body>
<form id="form1" runat="server"> <%--added by vithal wadje--%>
<div>
<asp:TextBox ID="TextBox1" runat="server"



</div>

<input type ="button" onclick ="data()" runat ="server" value="Submit" />
</form>
</body>
</html>








</pre>
[no name] 15-Sep-12 5:20am    
very useful

I think sometimes your message is coming with special characters like ' (Single Quote) or " (Double Quote). Try removing that from the msg variable.
C#
string msg = "Doesn't match the words .";
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Success", "alert('Notification : " + msg + "');window.location='Home.aspx';", true);


Hope it helps.
--Amit
 
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