Problem with Simple Example

R

rtk.richard

Hi,
I used OWC with ASP a few years ago and am now trying to get a
spreadsheet working with .NET. I tried on VS 2005 but that seemed
impossible so am now sitting here with VS.NET and Alvin's Black Book.
I'm doing the OWC Spreadsheet Example in CHapter 8 but can't get the
project to build. I have a spreadsheet on my form:
<OBJECT id="sp" style="Z-INDEX: 104; LEFT: 56px; POSITION: absolute;
TOP: 16px" classid=clsid:0002E559-0000-0000-C000-000000000046
VIEWASTEXT>
and have an event on the load button:
private void load_Click(object sender, System.EventArgs e)
{
sp.CSVDATA = "1,2,3,4,5,6,7,8,9,10";
}
I just get the error:
C:\Inetpub\wwwroot\WebApplication2\WebForm1.aspx.cs(53): The type or
namespace name 'sp' could not be found (are you missing a using
directive or an assembly reference?)
Should I have something linked that isn't?
I'm "Using"
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
and the ASPX header is:
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs"
AutoEventWireup="false" Inherits="WebApplication2.WebForm1" %>

THanks in advance for any pointes!
 
A

Alvin Bruney [MVP]

you can't do 'sp' because the spreadsheet is a client-side object (read
javascript). So codebehind won't work. Or it will but with some
modifications:


private void load_Click(object sender, system.EventArgs e)
{
Response.Write("<script>document.all.sp.CSVDATA =
'1,2,3,4,5,6,7,8,9,10'</script>");
}

Anything you do with the control must be thru script, there is no way to use
the codebehind approach because the codebehind execution happens on the
server. The OWC controls live in the browser. Think of the OWC as an html
button control. It's entirely different from a server button control. make
sense?
--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
 
R

rtk.richard

Thanks Alvin,

I understand now I think. I'll try JavaScript. Presumably I can use
aspx to "write" the script for me if necessary.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top