Rinshad Hameed
Rinshad Hameed

Reputation: 117

Make asp label invisible using timer

i have to show a label indicating success of insertion of data. The label should disappear automatically after 5 seconds how can i achieve this??

 <html>
 <head id="Head1" runat="server">
 <title>Test Visibility</title>
 <script type="text/javascript">
  $(document).ready(function () {
    setTimeout(function () {
        $('#<%= lblError.ClientID%>').hide();
    }, 100); // <-- time in milliseconds
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>

<asp:Label ID="lblError" runat="server" Text="Label"></asp:Label>
</div>
 </form>
</body>
</html>

Upvotes: 1

Views: 1713

Answers (1)

शेखर
शेखर

Reputation: 17614

You can use jquery for this.
Call a function and it will hide it after a particular duration.

setTimeout(function() {
   $('#labelId').hide();
}, 1000); // <-- time in milliseconds

Suppose you have a label

  <asp:Label ID="lblResult" runat="server" Text=""></asp:Label>

So you can use it as follows

  setTimeout(function() {
   $('#<%= lblResult.ClientId%>').hide();
}, 1000); // <-- time in milliseconds

and in document.ready call it.

$(document).ready(function() {
       setTimeout(function() {
   $('#<%= lblResult.ClientId%>').hide();
}, 1000); // <-- time in milliseconds
});

Upvotes: 2

Related Questions