<Object> Is undefined

Discussion in 'Microsoft ASP .NET' started by Sam Samnah, Jun 13, 2005.

  1. Sam Samnah

    Sam Samnah Guest

    I posted this during the weekend and I think it was missed so I am posting
    it again. I'm in real big trouble with this and need help desperately. Any
    suggestions will be met with unbelievable gratitude.
    I don't know why but on the outputed page the dialog helper id is not
    recognized or is "undefined" Can someone tell suggest what I am doing
    wrong? I've been going over this goodness knows how many times and I can't
    figure it out. The Object is set on the page properly but is not recognized
    in the javascript. Some one please help.

    Below is the code.

    Thank you in advance,

    Sam I am-

    protected override void OnLoad(EventArgs e)

    {

    base.OnLoad (e);

    if(!Page.IsClientScriptBlockRegistered("startup"))

    {

    StringBuilder jsload=new StringBuilder();

    jsload.Append(@"<script language='javascript' type='text/javascript'>" +
    "\n");

    jsload.Append(@"window.onload=doInit;" + "\n");

    jsload.Append(@"function doInit()" + "\n");

    jsload.Append(@"{" + "\n");

    jsload.Append("\t" + @"for(i=0;i<document.all.length;i++)" + "\n");

    jsload.Append("\t\t" + @"document.all(i).unselectable = 'on';" + "\n");

    jsload.Append("\t\t" + @"oDiv.unselectable = 'off';" + "\n");

    jsload.Append("\t\t" + @"oDiv.innerHTML='';" +"\n");

    jsload.Append("\t\t" + @"oDiv.focus();" + "\n");

    jsload.Append("\t\t" + @"getSystemFonts();" + "\n");

    jsload.Append(@"}" + "\n");

    jsload.Append(@"function callFormating(sformatString)" + "\n" + "{" + "\n");

    jsload.Append("\t" + @"document.execCommand(sformatString);" + "\n");

    jsload.Append(@"}" + "\n");

    jsload.Append(@"function moveCurser(" + this.UniqueID + ")" + "\n" + "{" +
    "\n");

    jsload.Append("\t" + @"var i;" + "\n");

    jsload.Append("\t" + @"i=document.getElementById('oDiv');" + "\n");

    jsload.Append("\t" + this.UniqueID + @".value=i.innerHTML;" + "\n");

    jsload.Append(@"}" + "\n");

    This the problem javascript:

    jsload.Append(@"function getSystemFonts()" + "\n" + "{" + "\n");

    jsload.Append("\t" + @"var a=dlgHelper.fonts.count;" + "\n");

    jsload.Append("\t" + @"var fArray=new fArray();" + "\n");

    jsload.Append("\t" + @"var
    oDropDown=document.getElementByID(oToolbar1).createDropDownListAt('1');" +
    "\n");

    jsload.Append("\t" + @"oDropDown.setAttribute('ID','FontNameList');" +
    "\n");

    jsload.Append("\t" + @"for(i=1;i<dlgHelper.fonts.count;i++)" + "\n" + "\t" +
    "{" + "\n");

    jsload.Append("\t\t" + @"fArray = dlgHelper.fonts(i);" + "\n");

    jsload.Append("\t\t" + @"var aOptions = oDropDown.getOptions();" + "\n");

    jsload.Append("\t\t" + @"var oOption = document.createElement('OPTION');" +
    "\n");

    jsload.Append("\t\t" + @"aOptions.add(oOption);" + "\n");

    jsload.Append("\t\t" + @"oOption.text = fArray;" + "\n");

    jsload.Append("\t\t" + @"oOption.Value = i;" + "\n" + "\t" + "}" + "\n");

    jsload.Append("\t" + @"oDropDown.setAttribute('onchange',ChangeFormat);" +
    "\n" + "}" + "\n");

    jsload.Append(@"function ChangeFormat()" + "\n" + "{" + "\n");

    jsload.Append("\t" + @"var
    sSelected2=document.getElementById(FontNameList);" + "\n");

    jsload.Append("\t" + @"var
    sSelected3=sSelected2.Options(sSelected2.selectedIndex);" + "\n");

    jsload.Append("\t" +
    @"document.execCommand('FontName',false,sSelected3.text);" + "\n");

    jsload.Append("}" + "\n");

    jsload.Append(@"function changeFontSize(strid)" + "\n" + "{" + "\n");

    jsload.Append("\t" + @"var sSelected1=document.getElementById(strid);" +
    "\n");

    jsload.Append("\t" + @"var
    sSelected=sSelected1.options(sSelected1.selectedIndex);" + "\n");

    jsload.Append("\t" +
    @"document.execCommand('FontSize',false,sSelected.value);" + "\n");

    jsload.Append(@"}" + "\n");

    jsload.Append(@"</script>" + "\n");


    string CMSUpReg=jsload.ToString();

    Page.RegisterClientScriptBlock("Startup",CMSUpReg);

    }

    }

    This is the where the object is rendered

    protected override void OnPreRender(EventArgs e)

    {

    base.OnPreRender (e);

    if(!Page.IsClientScriptBlockRegistered("jObject"))

    {

    StringBuilder jsObject=new StringBuilder();

    jsObject.Append(@"<Object id='dlgHelper'
    CLASSID='clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b' Width='0'
    Height='0'></Object>" + "\n");

    string strjsObject=jsObject.ToString();

    Page.RegisterClientScriptBlock("jObject",strjsObject);

    }

    }
     
    Sam Samnah, Jun 13, 2005
    #1
    1. Advertisements

  2. Sam Samnah

    Scott Allen Guest

    Hi Sam:

    It might be easier to debug if you did a View -> Source on the page
    and posted the resulting JavaScript. I'm assuming this is an error
    that occurs in the java script itself?

    --
    Scott
    http://www.OdeToCode.com/blogs/scott/

    On Mon, 13 Jun 2005 08:15:25 -0400, "Sam Samnah"
    <> wrote:

    >I posted this during the weekend and I think it was missed so I am posting
    >it again. I'm in real big trouble with this and need help desperately. Any
    >suggestions will be met with unbelievable gratitude.
    >I don't know why but on the outputed page the dialog helper id is not
    >recognized or is "undefined" Can someone tell suggest what I am doing
    >wrong? I've been going over this goodness knows how many times and I can't
    >figure it out. The Object is set on the page properly but is not recognized
    >in the javascript. Some one please help.
    >
    >Below is the code.
    >
    >Thank you in advance,
    >
    >Sam I am-
    >
    >protected override void OnLoad(EventArgs e)
    >
    >{
    >
    >base.OnLoad (e);
    >
    >if(!Page.IsClientScriptBlockRegistered("startup"))
    >
    >{
    >
    >StringBuilder jsload=new StringBuilder();
    >
    >jsload.Append(@"<script language='javascript' type='text/javascript'>" +
    >"\n");
    >
    >jsload.Append(@"window.onload=doInit;" + "\n");
    >
    >jsload.Append(@"function doInit()" + "\n");
    >
    >jsload.Append(@"{" + "\n");
    >
    >jsload.Append("\t" + @"for(i=0;i<document.all.length;i++)" + "\n");
    >
    >jsload.Append("\t\t" + @"document.all(i).unselectable = 'on';" + "\n");
    >
    >jsload.Append("\t\t" + @"oDiv.unselectable = 'off';" + "\n");
    >
    >jsload.Append("\t\t" + @"oDiv.innerHTML='';" +"\n");
    >
    >jsload.Append("\t\t" + @"oDiv.focus();" + "\n");
    >
    >jsload.Append("\t\t" + @"getSystemFonts();" + "\n");
    >
    >jsload.Append(@"}" + "\n");
    >
    >jsload.Append(@"function callFormating(sformatString)" + "\n" + "{" + "\n");
    >
    >jsload.Append("\t" + @"document.execCommand(sformatString);" + "\n");
    >
    >jsload.Append(@"}" + "\n");
    >
    >jsload.Append(@"function moveCurser(" + this.UniqueID + ")" + "\n" + "{" +
    >"\n");
    >
    >jsload.Append("\t" + @"var i;" + "\n");
    >
    >jsload.Append("\t" + @"i=document.getElementById('oDiv');" + "\n");
    >
    >jsload.Append("\t" + this.UniqueID + @".value=i.innerHTML;" + "\n");
    >
    >jsload.Append(@"}" + "\n");
    >
    >This the problem javascript:
    >
    >jsload.Append(@"function getSystemFonts()" + "\n" + "{" + "\n");
    >
    >jsload.Append("\t" + @"var a=dlgHelper.fonts.count;" + "\n");
    >
    >jsload.Append("\t" + @"var fArray=new fArray();" + "\n");
    >
    >jsload.Append("\t" + @"var
    >oDropDown=document.getElementByID(oToolbar1).createDropDownListAt('1');" +
    >"\n");
    >
    >jsload.Append("\t" + @"oDropDown.setAttribute('ID','FontNameList');" +
    >"\n");
    >
    >jsload.Append("\t" + @"for(i=1;i<dlgHelper.fonts.count;i++)" + "\n" + "\t" +
    >"{" + "\n");
    >
    >jsload.Append("\t\t" + @"fArray = dlgHelper.fonts(i);" + "\n");
    >
    >jsload.Append("\t\t" + @"var aOptions = oDropDown.getOptions();" + "\n");
    >
    >jsload.Append("\t\t" + @"var oOption = document.createElement('OPTION');" +
    >"\n");
    >
    >jsload.Append("\t\t" + @"aOptions.add(oOption);" + "\n");
    >
    >jsload.Append("\t\t" + @"oOption.text = fArray;" + "\n");
    >
    >jsload.Append("\t\t" + @"oOption.Value = i;" + "\n" + "\t" + "}" + "\n");
    >
    >jsload.Append("\t" + @"oDropDown.setAttribute('onchange',ChangeFormat);" +
    >"\n" + "}" + "\n");
    >
    >jsload.Append(@"function ChangeFormat()" + "\n" + "{" + "\n");
    >
    >jsload.Append("\t" + @"var
    >sSelected2=document.getElementById(FontNameList);" + "\n");
    >
    >jsload.Append("\t" + @"var
    >sSelected3=sSelected2.Options(sSelected2.selectedIndex);" + "\n");
    >
    >jsload.Append("\t" +
    >@"document.execCommand('FontName',false,sSelected3.text);" + "\n");
    >
    >jsload.Append("}" + "\n");
    >
    >jsload.Append(@"function changeFontSize(strid)" + "\n" + "{" + "\n");
    >
    >jsload.Append("\t" + @"var sSelected1=document.getElementById(strid);" +
    >"\n");
    >
    >jsload.Append("\t" + @"var
    >sSelected=sSelected1.options(sSelected1.selectedIndex);" + "\n");
    >
    >jsload.Append("\t" +
    >@"document.execCommand('FontSize',false,sSelected.value);" + "\n");
    >
    >jsload.Append(@"}" + "\n");
    >
    >jsload.Append(@"</script>" + "\n");
    >
    >
    >string CMSUpReg=jsload.ToString();
    >
    >Page.RegisterClientScriptBlock("Startup",CMSUpReg);
    >
    >}
    >
    >}
    >
    >This is the where the object is rendered
    >
    >protected override void OnPreRender(EventArgs e)
    >
    >{
    >
    >base.OnPreRender (e);
    >
    >if(!Page.IsClientScriptBlockRegistered("jObject"))
    >
    >{
    >
    >StringBuilder jsObject=new StringBuilder();
    >
    >jsObject.Append(@"<Object id='dlgHelper'
    >CLASSID='clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b' Width='0'
    >Height='0'></Object>" + "\n");
    >
    >string strjsObject=jsObject.ToString();
    >
    >Page.RegisterClientScriptBlock("jObject",strjsObject);
    >
    >}
    >
    >}
    >
     
    Scott Allen, Jun 13, 2005
    #2
    1. Advertisements

  3. Sam Samnah

    Guest Guest

    It looks like a JS error, so you will have to render the page and pull the
    JavaScript to see what is or is not being loaded. Walk through the JavaScript
    rendered, line by line, and see if you can spot the error.

    A second suggestion is step through the code line by line and look at what
    variables are set. You might see a mistake in your thinking here.

    It is increasingly hard to determine errors when part of your code is behind
    the scenes (server code) and part is in front (client code) as the error can
    be on either side.

    --
    Gregory A. Beamer
    MVP; MCP: +I, SE, SD, DBA

    ***************************
    Think Outside the Box!
    ***************************


    "Sam Samnah" wrote:

    > I posted this during the weekend and I think it was missed so I am posting
    > it again. I'm in real big trouble with this and need help desperately. Any
    > suggestions will be met with unbelievable gratitude.
    > I don't know why but on the outputed page the dialog helper id is not
    > recognized or is "undefined" Can someone tell suggest what I am doing
    > wrong? I've been going over this goodness knows how many times and I can't
    > figure it out. The Object is set on the page properly but is not recognized
    > in the javascript. Some one please help.
    >
    > Below is the code.
    >
    > Thank you in advance,
    >
    > Sam I am-
    >
    > protected override void OnLoad(EventArgs e)
    >
    > {
    >
    > base.OnLoad (e);
    >
    > if(!Page.IsClientScriptBlockRegistered("startup"))
    >
    > {
    >
    > StringBuilder jsload=new StringBuilder();
    >
    > jsload.Append(@"<script language='javascript' type='text/javascript'>" +
    > "\n");
    >
    > jsload.Append(@"window.onload=doInit;" + "\n");
    >
    > jsload.Append(@"function doInit()" + "\n");
    >
    > jsload.Append(@"{" + "\n");
    >
    > jsload.Append("\t" + @"for(i=0;i<document.all.length;i++)" + "\n");
    >
    > jsload.Append("\t\t" + @"document.all(i).unselectable = 'on';" + "\n");
    >
    > jsload.Append("\t\t" + @"oDiv.unselectable = 'off';" + "\n");
    >
    > jsload.Append("\t\t" + @"oDiv.innerHTML='';" +"\n");
    >
    > jsload.Append("\t\t" + @"oDiv.focus();" + "\n");
    >
    > jsload.Append("\t\t" + @"getSystemFonts();" + "\n");
    >
    > jsload.Append(@"}" + "\n");
    >
    > jsload.Append(@"function callFormating(sformatString)" + "\n" + "{" + "\n");
    >
    > jsload.Append("\t" + @"document.execCommand(sformatString);" + "\n");
    >
    > jsload.Append(@"}" + "\n");
    >
    > jsload.Append(@"function moveCurser(" + this.UniqueID + ")" + "\n" + "{" +
    > "\n");
    >
    > jsload.Append("\t" + @"var i;" + "\n");
    >
    > jsload.Append("\t" + @"i=document.getElementById('oDiv');" + "\n");
    >
    > jsload.Append("\t" + this.UniqueID + @".value=i.innerHTML;" + "\n");
    >
    > jsload.Append(@"}" + "\n");
    >
    > This the problem javascript:
    >
    > jsload.Append(@"function getSystemFonts()" + "\n" + "{" + "\n");
    >
    > jsload.Append("\t" + @"var a=dlgHelper.fonts.count;" + "\n");
    >
    > jsload.Append("\t" + @"var fArray=new fArray();" + "\n");
    >
    > jsload.Append("\t" + @"var
    > oDropDown=document.getElementByID(oToolbar1).createDropDownListAt('1');" +
    > "\n");
    >
    > jsload.Append("\t" + @"oDropDown.setAttribute('ID','FontNameList');" +
    > "\n");
    >
    > jsload.Append("\t" + @"for(i=1;i<dlgHelper.fonts.count;i++)" + "\n" + "\t" +
    > "{" + "\n");
    >
    > jsload.Append("\t\t" + @"fArray = dlgHelper.fonts(i);" + "\n");
    >
    > jsload.Append("\t\t" + @"var aOptions = oDropDown.getOptions();" + "\n");
    >
    > jsload.Append("\t\t" + @"var oOption = document.createElement('OPTION');" +
    > "\n");
    >
    > jsload.Append("\t\t" + @"aOptions.add(oOption);" + "\n");
    >
    > jsload.Append("\t\t" + @"oOption.text = fArray;" + "\n");
    >
    > jsload.Append("\t\t" + @"oOption.Value = i;" + "\n" + "\t" + "}" + "\n");
    >
    > jsload.Append("\t" + @"oDropDown.setAttribute('onchange',ChangeFormat);" +
    > "\n" + "}" + "\n");
    >
    > jsload.Append(@"function ChangeFormat()" + "\n" + "{" + "\n");
    >
    > jsload.Append("\t" + @"var
    > sSelected2=document.getElementById(FontNameList);" + "\n");
    >
    > jsload.Append("\t" + @"var
    > sSelected3=sSelected2.Options(sSelected2.selectedIndex);" + "\n");
    >
    > jsload.Append("\t" +
    > @"document.execCommand('FontName',false,sSelected3.text);" + "\n");
    >
    > jsload.Append("}" + "\n");
    >
    > jsload.Append(@"function changeFontSize(strid)" + "\n" + "{" + "\n");
    >
    > jsload.Append("\t" + @"var sSelected1=document.getElementById(strid);" +
    > "\n");
    >
    > jsload.Append("\t" + @"var
    > sSelected=sSelected1.options(sSelected1.selectedIndex);" + "\n");
    >
    > jsload.Append("\t" +
    > @"document.execCommand('FontSize',false,sSelected.value);" + "\n");
    >
    > jsload.Append(@"}" + "\n");
    >
    > jsload.Append(@"</script>" + "\n");
    >
    >
    > string CMSUpReg=jsload.ToString();
    >
    > Page.RegisterClientScriptBlock("Startup",CMSUpReg);
    >
    > }
    >
    > }
    >
    > This is the where the object is rendered
    >
    > protected override void OnPreRender(EventArgs e)
    >
    > {
    >
    > base.OnPreRender (e);
    >
    > if(!Page.IsClientScriptBlockRegistered("jObject"))
    >
    > {
    >
    > StringBuilder jsObject=new StringBuilder();
    >
    > jsObject.Append(@"<Object id='dlgHelper'
    > CLASSID='clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b' Width='0'
    > Height='0'></Object>" + "\n");
    >
    > string strjsObject=jsObject.ToString();
    >
    > Page.RegisterClientScriptBlock("jObject",strjsObject);
    >
    > }
    >
    > }
    >
    >
    >
     
    Guest, Jun 13, 2005
    #3
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mike John

    Error: 'WScript' is undefined'

    Mike John, Jul 8, 2003, in forum: Microsoft ASP .NET
    Replies:
    1
    Views:
    1,198
    Natty Gur
    Jul 8, 2003
  2. DesignerX

    JavaScript Error: 'Page_Validators' is undefined

    DesignerX, Jul 24, 2003, in forum: Microsoft ASP .NET
    Replies:
    2
    Views:
    747
    DesignerX
    Jul 25, 2003
  3. Ravikanth[MVP]

    Page_Validators is undefined

    Ravikanth[MVP], Aug 26, 2003, in forum: Microsoft ASP .NET
    Replies:
    2
    Views:
    3,466
    sramruttun
    Aug 27, 2003
  4. Felipe

    'Undefined' Client-Side Object Reference

    Felipe, Jul 15, 2004, in forum: Microsoft ASP .NET
    Replies:
    3
    Views:
    181
    Felipe
    Jul 16, 2004
  5. siddhath
    Replies:
    4
    Views:
    907
    Mohamad Elarabi [MCPD]
    Jan 2, 2008
Loading...

Share This Page