Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Sep 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Object Required Error

    Hi ,

    I have used javascript coding in my Asp.Net application like this

    <script language="javascript">
    function Button1_Click()
    {

    //switch(Select1.selectedIndex)


    //Case 0 // Use Automation.;
    var sHTML;
    sHTML =document.forms(0).children("dg1").outerhtml;
    var oXL, oBook;
    oXL = new ActiveXObject("Excel.Application");
    //Set oXL = new ActiveXObject(".Application");
    oBook = oXL.Workbooks.Add;
    oBook.HTMLProject.HTMLProjectItems("Sheet1").Text = sHTML;
    oBook.HTMLProject.RefreshDocument;
    oXL.Visible = true;
    oXL.UserControl = true;

    //Case 1 // Use MIME Type (In a New Window).;
    window.open("bottom.aspx?bExcel=1")

    //Case 2 // Use MIME Type (In the Frame).;
    //window.parent.frames("bottom").navigate "bottom.aspx?bExcel=1";

    }

    </script>

    When i run it i get an error: "object required" in this particular line:
    sHTML =document.forms(0).children("dg1").outerhtml;
    Can anybody help me please?

    Regards
    Vijay

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    () is a function/method
    [] is an array/object

    document.forms[0].elements["elementName"]

    if you are using a ASP control the elementname is chnaged by the server.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •