Re: OWC Events in .Net

From: Alvin Bruney [MVP] (vapor)
Date: 10/11/04


Date: Mon, 11 Oct 2004 12:12:33 -0500

You took a couple wrong turns. Events always work on the client. There is no
need to go thru the event set up process. This is only needed for
server-side applications. Basically, drag a spread*** component onto the
webform. You will be responsible for writing javascript code to load and
unload the control. The manipulation must be done from the client because it
is a client control.

For the unload process, place a text box on the form, set it's visible
property to false. Put a webserver button on the form. Set its click event
to a loadData function that you will write next.

For the loadData function, unload the contents of the spread*** into the
server textbox control. texdbox1.text = sp1.CSVDATA;

The idea so far is that clicking on the webserver control will first execute
the client side function that causes the spread*** to unload its contents
to the textbox, then the webserver control will fire the page_load event
followed by the button_click event on the server. Ignore the button click
event. In your page_load event, test the contents of the textbox control and
iterate its contents to extract the data.
Here is the bulk of the code.

Page_Load

if(TextBox1.Text.Trim() != string.Empty)
{
    string[] rows = TextBox1.Text.ToString().Split(Environtment.Newline);
//or '\n'
    foreach(string str in rows)
    {
        string[] columns = rows.ToString().Split(',');
        foreach(string col in columns)
        {
            //collect your data per row here and do what you must
        }
    }
    //re-initialize
    TextBox1.Text = string.Empty;
}

Your load function follows roughly the same script idea, except that it
loads data

-- 
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27***
"Jeff Copeland" <anonymous@discussions.microsoft.com> wrote in message 
news:3a6801c4afa8$3070ec90$a401280a@phx.gbl...
> Alvin,
> Can you point me in the right direction?  I have spent
> too much time on this and I want to get a working
> solution.
> I have been able to write some vbscript to SS1.Export
> command for the spread*** but I want to do this via c#
> code if possible...Also when I do the export command I am
> always prompted if I want to save the file... is there a
> way to supress this?
> I want to control the spread*** via my c# code and not
> have to use vbscript.  Since I haven't been able to use
> the online Doc to recompile the dll I don't know if that
> will help me or not... Is there a way to just get a
> compiled DLL sent to me?  Frustrated...
>>-----Original Message-----
>>give me the exact error information and the line you
> followed to get that.
>>this needs to be corrected in the documentation and I
> keep forgetting to
>>submit it.
>>
>>the office web components are client-side controls. they
> run on the client,
>>not on the server. they do not have a handle on the
> server so you will not
>>be able to manipulate these controls from the server.
> However, you can use
>>attributes to attain some semblance of server-side
> automation. Have a look
>>at my website, it details some examples about the
> process.
>>http://tinyurl.com/27***
>>
>>-- 
>>Regards,
>>Alvin Bruney
>>[ASP.NET MVP
> http://mvp.support.microsoft.com/default.aspx]
>>Got tidbits? Get it here... http://tinyurl.com/27***
>>"WebComponentFlunky" <copeland573@sbcglobal.net> wrote
> in message
>>news:2c0d01c4ae04$7741ce00$a401280a@phx.gbl...
>>>I am trying to add a spread*** component to my web
> page
>>> in .NET (c#).  When I add the spread*** to my form I
>>> cannot use its methods from within my .net code.
>>> I found a Microsoft article #328275 'How to handle
> events
>>> for the Office Web Components in Visual Studio .NET'
>>> which basically walks you through the process of
>>> recompling a DLL which is part of the OWC controls...
>>> when I tried these steps, I always get compilied errors
>>> on step 11 (compile the source file, AxOWC10.cs).  I
> have
>>> tried this on two different machines... same result...
>>> I am just trying to get the spread*** control so
> that I
>>> can use its methods from my .net c# code... any ideas?
>>>
>>
>>
>>.
>>