The reason you get the error that "FpSpread1 is undefined" is that when
ASP.NET renders server controls it adds the namingcontainer id as a prefix to
the control id.
Instead of using the document.getElementById, try something like this:
var table = findControl("FpSpread1");
if (table !=null) //do all of the processing that you want
and write a function as this:
<script language="javascript">
function findControl(ControlName)
{
var aTables = document.getElementsByTagName("table");
if (aTables)
{ for (var i=0; i < aTables.length ; i++)
{
if (aTables[i].id.lastIndexOf(ControlName) == aTables[i].id.length -
ControlName.length)
{
ret =aTables[i];
}
}
}
return ret;
}
</script>
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"dchillman" wrote:
> I have a user control page (ascx) that contains a third-party spreasheet
> control. When the user clicks the insert button on the spreadsheet control,
> I am trying to pre-insert values into the new row. If I put the spreadsheet
> control directly on as aspx page, I can do this in the window.onload
> function. However, when the spreadsheet control in on an ascx page, I get an
> error that says the control is undefined.
>
> here is the code on the html page of the ascx.
>
> <script language="javascript">
>
> function window.onload()
> {
> //debugger
> var i;
> //var spreadRef = document.getElementById(FpSread1);
> var table = FpSread1.all("FpSpread1_viewPort").firstChild;
> for(i=1;i<=spreadRef.GetRowCount();i++)
> {
> if(table.rows[i].FpKey=="newRow")
> {
> alert("New Row");
> FpSread1.SetValue(i-1, 0, FpSread1.GetValue(i, 0));
> FpSread1.SetValue(i-1, 1, FpSread1.GetValue(i, 1));
> FpSread1.SetValue(i-1, 2, FpSread1.GetValue(i, 2));
> }
> }
>
> }
> </script>
>
> When the page loads, there is a yellow exclamation point that essentially
> states that
> "FpSpread1 is undefined".
>
> Is it possible to access a third party control within a user control on the
> clientside?
>
> Thanks for any help you can provide.
> --
> dchillman