...

View Full Version : Object Required Error



vijay_83
12-08-2006, 09:25 PM
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

A1ien51
12-08-2006, 10:36 PM
() 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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum