Script

G

Guest

I have coded java script and placed it into my code, by I have never used
VBScript.

Can I use VBScript with a C# page?

No matter where I place this script, it never successfully compiles in
VS.Net, I always am getting an error indicating the procedure was not found.
My code looks like the following...

<asp:button id="exportbutton" runat="server" Text="Create Excel File"
onclick="exportbutton_onclick()"></asp:button>

<script language="vbscript">
Sub exportbutton_onclick()

Dim sHTML, oExcel, oBook
sHTML = document.all.item("DataGrid1").outerhtml
Set oExcel = CreateObject("Excel.Application")=
Set oBook = oExcel.Workbooks.Add
oBook.HTMLProject.HTMLProjectItems("Sheet1").Text = sHTML
oBook.HTMLProject.RefreshDocument
oExcel.Visible = true
oExcel.UserControl = true

End Sub
</script>

The example that I am looking at tells me to place the script after the
</HTML> tag, which looks like a strange place to pu it. But I have tried
placing it in the body and in the head with the same result.

The example also does not show a "()" after the end of the method name, and
I added that , but both with and without, I get the same results.

What am I doing wrong?

VS.Net allows me to create a VBScript File, if I use this file, how do I get
it pulled in for processing?

Thanks
 
B

bruce barker

to fire your script donot use a server button, but a local button (you do
not want a postback).

<button id="exportbutton" value="Create Excel File"
onclick="exportbutton_onclick()">

the next problem, will be that the browser trust level needs to be high
enough to run excel.

-- bruce (sqlwork.com)


| I have coded java script and placed it into my code, by I have never used
| VBScript.
|
| Can I use VBScript with a C# page?
|
| No matter where I place this script, it never successfully compiles in
| VS.Net, I always am getting an error indicating the procedure was not
found.
| My code looks like the following...
|
| <asp:button id="exportbutton" runat="server" Text="Create Excel File"
| onclick="exportbutton_onclick()"></asp:button>
|
| <script language="vbscript">
| Sub exportbutton_onclick()
|
| Dim sHTML, oExcel, oBook
| sHTML = document.all.item("DataGrid1").outerhtml
| Set oExcel = CreateObject("Excel.Application")=
| Set oBook = oExcel.Workbooks.Add
| oBook.HTMLProject.HTMLProjectItems("Sheet1").Text = sHTML
| oBook.HTMLProject.RefreshDocument
| oExcel.Visible = true
| oExcel.UserControl = true
|
| End Sub
| </script>
|
| The example that I am looking at tells me to place the script after the
| </HTML> tag, which looks like a strange place to pu it. But I have tried
| placing it in the body and in the head with the same result.
|
| The example also does not show a "()" after the end of the method name,
and
| I added that , but both with and without, I get the same results.
|
| What am I doing wrong?
|
| VS.Net allows me to create a VBScript File, if I use this file, how do I
get
| it pulled in for processing?
|
| Thanks
|
 
N

Nicole Schenk

Jim said:
I have coded java script and placed it into my code, by I have never used
VBScript.

Can I use VBScript with a C# page?

No matter where I place this script, it never successfully compiles in
VS.Net, I always am getting an error indicating the procedure was not
found. My code looks like the following...

<asp:button id="exportbutton" runat="server" Text="Create Excel File"
onclick="exportbutton_onclick()"></asp:button>

<script language="vbscript">
Sub exportbutton_onclick()

Dim sHTML, oExcel, oBook
sHTML = document.all.item("DataGrid1").outerhtml
Set oExcel = CreateObject("Excel.Application")=
Set oBook = oExcel.Workbooks.Add
oBook.HTMLProject.HTMLProjectItems("Sheet1").Text = sHTML
oBook.HTMLProject.RefreshDocument
oExcel.Visible = true
oExcel.UserControl = true

End Sub
</script>

The example that I am looking at tells me to place the script after the
</HTML> tag, which looks like a strange place to pu it. But I have tried
placing it in the body and in the head with the same result.

The example also does not show a "()" after the end of the method name,
and I added that , but both with and without, I get the same results.

What am I doing wrong?

VS.Net allows me to create a VBScript File, if I use this file, how do I
get it pulled in for processing?

Thanks
To my knowled VBSCRIPT in dead in .net server. You might still find it in
the client. VBSCRTIP is replaced by the very capable VB.NET
 

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

Members online

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,701
Latest member
XavierQ83

Latest Threads

Top