0

I'm try to hide the label after few second but it is updating page continuously after 10sec, i just want it once time when i click save button label on display me successfully for 10sec and get disappear

protected void LinkBtnSave_Click(object sender, EventArgs e)
{
    lblWriteTest.Text = "";
    ClientScript.RegisterStartupScript(this.GetType(), "HideLabel", 
    "<script type=\"text/javascript\">setTimeout(\"document.getElementById('" +
    lblWriteTest.ClientID + "').style.display='none'\",10000)</script>");
}
Anders Abel
  • 67,989
  • 17
  • 150
  • 217
Mano
  • 97
  • 1
  • 12
  • I strongly suggest using jQuery and AJAX calls to do things like this. You get very robust plugins like jGrowl for this kind of "notification" bubbles. – vvohra87 Oct 29 '11 at 07:21
  • i have no idea how to use jQuery and AJAX – Mano Oct 29 '11 at 08:11
  • try using a timer. Set the label text. wait for 10 seconds and set visibility of label to false. then set timer.enabled to false. – Sandy Oct 29 '11 at 12:37
  • @Mano Then it's not too late to learn :) This sort of client script registering clog up the code behind when they should typically be run on the client side. To give this notification you will at the very least (using AJAX) cause a post-back or worse a full page reload. Much better to get started with jQuery and AJAX. – vvohra87 Oct 29 '11 at 14:37

1 Answers1

0

add this code on page load

ClientScript.RegisterStartupScript(this.GetType(), "HideLabel", "<script type=\"text/javascript\">function hide(){setTimeout(\"document.getElementById('" + lbl.ClientID + "').style.display='none'\",300)}</script>");
    btn.Attributes.Add("onclick", "return hide()");

i hope this will help you.

Nasir Mahmood
  • 1,445
  • 1
  • 13
  • 18