Refering .js file from content page

Thread is closed for posting
3 posts, 0 answers
  1. Nalini
    Nalini avatar
    7 posts
    Member since:
    Jul 2010

    Posted 01 Sep 2010 Link to this post

    I am getting “Micorsoft Jscript runtime error: Object required” error when I try to refer the .js file that refer a Radcontrol. ie.,"document.getElementById('<%=txtTime.ClientID%>')."  Please let me know where i am going wrong.  Any help is appreciated.

    I originally have the following JavaScript function in the content page and worked just fine. Now I am trying to move my java script to .js file.

    I have the RadScriptManager on the master page. I do not want to load the .js code at the master  page, so I added a ScriptManagerProxy in my content page as below.
       <asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">
            <asp:ScriptReference Path="../JavaScript/test.js" />

    Sample Content of my test.js file

    function getTime(sender, args){
             var strTime =document.getElementById('<%=txtTime.ClientID%>').value;
                      args.IsValid = true;   

    Thanks in advance.

  2. Vinkel
    Vinkel avatar
    36 posts
    Member since:
    Apr 2010

    Posted 02 Sep 2010 Link to this post

    I bet you get the same error when you use server tags and client ids in test.js file for asp Button (for example), dear Nalini, don't you? My way is to define global js variable like so (inside pageLoaded client event of MS Ajax framework):

    var txtTimeObj = document.getElementById('<%=txtTime.ClientID%>')

    and then use txtTime object directly in test.js file.

    function getTime(sender, args)
             var strTime =txtTimeObj.value;
             args.IsValid = true;   

    Good luck!

  3. Nalini
    Nalini avatar
    7 posts
    Member since:
    Jul 2010

    Posted 09 Sep 2010 Link to this post

    Thank you very much for your suggestion.

Back to Top