Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7952989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:01:46+00:00 2026-06-04T03:01:46+00:00

protected void Page_Load(object sender, EventArgs e) { if(!Page.IsPostBack) divStatus.Visible = true; Page.ClientScript.RegisterStartupScript(this.GetType(), somekey, function

  • 0
protected void Page_Load(object sender, EventArgs e)
        {
            if(!Page.IsPostBack)
                divStatus.Visible = true;
                Page.ClientScript.RegisterStartupScript(this.GetType(), "somekey", "function autoHide(){ setTimeout(function() {document.getlementById('" + divStatus.ClientID + "').style.display='none';},5000);};", true); 
        }

  <form id="form1" runat="server">
    <div>
    <div class="success" id="divStatus" runat="server" visible="false" >sssssssssssssssss</div>

    </div>
    </form>

what exactly do i need to add in order to fadeout by itself after few seconds? currently i am displaying div but the user have to click explcitly to close the div and is there a way to close the div by itself using asp.net?

yes i know it does work with fadein and fadeout if you provide the timer but it does not work with asp.net code behind.

//html:

 <div class="success" id="divStatus" runat="server" visible="false" ></div>

//code behind:

protected void lnkbtn_add_Click(object sender, EventArgs e)
{
       ........//more code for deleting
       if (deleted)
       {
           divStatus.visible = true;
       }
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T03:01:48+00:00Added an answer on June 4, 2026 at 3:01 am

    Yes i know it does work with fadein and fadeout if you provide the
    timer but it does not work with asp.net code behind.

    There’s no difference. ASP.NET controls render as regular html controls. My hunch is that you are not using the proper client ID that’s rendered. You have two choices:

    • Add ClientIDMode=”static” in your markup as so:

      <div clientidmode="static" class="success" id="divStatus" runat="server" visible="false" ></div>
      

    And then add the javascript function to automatically hide the div:

    function autoHide()
    {  //hide after 5 seconds
       setTimeout(function(){document.getlementById('divStatus').style.display='none';},5000);
    }
    
    • simply use <%=divStatus.ClientID%> to get the client id that’s
      ultimately rendered on the page as so:

      function autoHide() {  //hide after 5 seconds   
        setTimeout(function() {document.getlementById('<%=divStatus.ClientID%>').style.display='none';},5000);
      }
      

    From codebehind, you can simply call:

     ........//more code for deleting
    Page.ClientScript.RegisterStartupScript(this.GetType(),"somekey","autoHide();",false);
    

    UPDATE

    If you want to even define the autoHide function in code behind, do as follows (note that the last parameter is true in this case, as opposed to false on the previous example):

     ........//more code for deleting
    string script = @"document.getElementById('" + divStatus.ClientID + "').innerHTML='You are done!' ;setTimeout(function(){document.getElementById('" + divStatus.ClientID + "').style.display='none';},5000);";
    Page.ClientScript.RegisterStartupScript(this.GetType(), "somekey", script, true);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack) {
Then: protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { CheckBoxList1.Items.Add(new ListItem(item1)); CheckBoxList1.Items.Add(new
this is the simple code: protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack)
Code Behind (C#): protected void Page_Load(object sender, EventArgs e) { try { if (!Page.IsPostBack)
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { loadCountries(); loadRegions(); loadCities(); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { Response.Cache.SetCacheability(HttpCacheability.NoCache ); Response.Cache.SetAllowResponseInBrowserHistory(false); }
In the pageload i populate a dropdownlist like this: protected void Page_Load(object sender, EventArgs
I have AutoEventWireup=true and in my code behind protected void Page_Init(object sender, EventArgs e)
protected void Button3_Click(object sender, EventArgs e) //export { GridView2.AllowPaging = false; GridViewExportUtil.Export(Сводка.xls, this.GridView2); GridView2.AllowPaging
On PostBack, from clicking on an ImageButton, it first hits protected void Page_Load(object sender,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.