Click here to Skip to main content
14,836,169 members
Please Sign up or sign in to vote.
1.00/5 (5 votes)
See more:
Hello,


XML
int microSeconds = 10 * 1000;
      StringBuilder theScript = new StringBuilder();
      theScript.Append("<script type='text/javascript'>");
       theScript.Append(" var MyTimer;");
      theScript.Append("if (document.getElementById('" + divMessage.ClientID + "') != null)");
      theScript.Append("clearTimeout(MyTimer);");
      theScript.Append(" MyTimer=setTimeout(\"document.getElementById('" + divMessage.ClientID + "').style.display='none'\", " + microSeconds + ");");
      theScript.Append("</script>");

      ScriptManager.RegisterStartupScript(Page, typeof(Page), "hides", theScript.ToString(), false);




Error:Microsoft JScript runtime error: Object required

Pls Help
Posted
Comments
[no name] 24-Dec-10 0:02am
   
Have you debugged? On which line does the error occur?
NITHIN INDIA 24-Dec-10 0:05am
   
@ Run Time
Dr.Walt Fair, PE 24-Dec-10 0:26am
   
First you need to get and use a Javascipt debugger. I use Firebug for Firefox - it's free. With that you can tell which line of code is causing your problem at run time.

Once you've done that, then either the problem will be obvious so you can fix it, or you'll have enough information so that we can help you.
NITHIN INDIA 24-Dec-10 1:14am
   
i want to hide "Div " after some second ,and also clear its timer pls help
Sunasara Imdadhusen 24-Dec-10 5:12am
   
Please provide HTML page code!

1 solution

Simple. One of the objects you are referencing in your javascript does not exist (ie. It is null) when you are attempting to access a function under it. Take the advice above, install a javascript debugger and then figure out which object doesn't exist. If you don't know how to install a debugger, or you can't install a debugger, just add a temporary alert before you use each object.
ie. Before you have the divMessage.ClientID call, put in an if block and alert...
if( !divMessage || !divMessage.ClientID ) alert( "divMessage is null or divMessage.ClientID is null");
   
Comments
Manfred Rudolf Bihy 24-Dec-10 12:22pm
   
Wow, now that seems to me more than he could possibly have hoped for after leaving that code.

Good advice! +5
fjdiewornncalwe 24-Dec-10 12:34pm
   
Just trying to keep you with you, Manfred...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900