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

  • Home
  • SEARCH
  • 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 867713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:01:31+00:00 2026-05-15T10:01:31+00:00

On load I’m both calling a JavaScript setTimeout() function that will hide a .NET

  • 0

On load I’m both calling a JavaScript setTimeout() function that will hide a .NET Panel control, and hiding it in the code behind on first load. Clicking the save button will set the Panel to visible then reload the page at which point a setTimeout() function is called… so basically you click save, and see a panel with “Details Saved” for three seconds, at which point it disappears.

The problem is the external JavaScript file can’t find _pDivAlert.ClientID (I’ve debugged and it returns null). It only works when the code is in a tag in the .aspx page. Any suggestions as to how I can either pass the client ID to the HideControl() function or find the ClientID from the external JS file?

Here’s my code, any suggestions?

<script language="javascript" src="Forms.js" type="text/javascript"></script>

<body onload="ToggleAlert()">
<form id="form1" runat="server">
<script type="text/javascript">
    //alert the user that the details were saved
    function HideControl() {
        var control = document.getElementById('<%=_pDivAlert.ClientID %>');
        if(control != null)
            control.style.display = 'none';
    }
    function ToggleAlert() {
        setTimeout("HideControl()", 3000);
    }
</script>

I’ve also tried sending the ClientID within the ToggleAlert() call, but that didn’t work:

<body onload="ToggleAlert('<%=_pDivAlert.ClientID %>')">

External JS:

function HideControl(_c) {
var control = _c;
if (control != null)
    control.style.display = 'none';
}
function ToggleAlert(_c) {
    setTimeout("HideControl(_c)", 3000);
}
  • 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-05-15T10:01:32+00:00Added an answer on May 15, 2026 at 10:01 am

    can you show your markup with the panel and the codebehind where you hide it?

    there’s a difference between setting the Visible property to false and setting the style display attribute to none- the first will not render the element at all, meaning there isn’t anything rendered with the id you’re looking for.

    edit: it’s probably because of the way you’re calling HideControl in the timeout- this should be a function instead of a string.

    try doing

    function ToggleAlert(_c) {
        setTimeout( 
            function () { 
                HideControl(_c); 
            }, 3000);
    }
    

    just for clarity, when you pass a string to setTimeout, it’s evaluated and then run. the code chunk that eval produces will run in a different scope than your ToggleAlert method, and so _c won’t be available at that time.

    edit: you also need to actually get a reference to the control. you’re passing the id string to ToggleAlert, which relays it to HideControl, which is expecting an object not a string.

    function HideControl(_c) { // _c is the id of the element
        var control = document.getElementById(_c);
        if (control != null)
            control.style.display = 'none';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

using .load(url) , but is there an Ajax .reload() function that can be used
google.load(feeds, 1); function OnLoad() { // Create a feed control var feedControl = new
I load some HTML code into a div with the .load function af jQuery
I load a Datatable to a datagrid view by calling the following function: Public
load.js: jQuery(document).ready(function($) { $('.dialog ul li').click(function(e) { switch($(this).attr('id')) { case 'addProject': $('.addDialog').load('/add/addprojectform'); break; case
I load a contacts picture from the address book using the following code: -
I load an image into an ImageView using .setImageURI(selectedImageUri) that is retrieved from the
I load some html using AJAX, this works fine, one of the bits that
html load coming from NSString. I have the following problem: I get html code
I load an xml $.ajax({ url: '../rest/', dataType: xml, success: showXML }); function showXML(xml)

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.