Designer Source Code:
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<style type="text/css">
body
{
font-family: Arial;
font-size: 10pt;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
Enter Name:
<asp:TextBox ID="txtName" runat="server" />
<br />
<asp:Button ID="Button1" Text="Submit" runat="server" OnClick="Submit" /><br />
<br />
<asp:Label ID="lblMessage" ForeColor="Green" Font-Bold="true" Text="Form
has been submitted
successfully."
runat="server" Visible="false" />
</ContentTemplate>
</asp:UpdatePanel>
<script type="text/javascript">
function hideuser() {
window.setTimeout(function () {
// This will execute 5 seconds later
var label =
document.getElementById('lblMessage');
if (label != null) {
label.style.display = 'none';
}
}, 5000);
}
</script>
</form>
</body>
</html>
Code Behind :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class hidelabel : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Submit(object sender, EventArgs e)
{
lblMessage.Visible = true;
System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page,
typeof(Page), "Script", "hideuser();", true);
}
}
No comments:
Post a Comment