473,406 Members | 2,345 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to create a Server Object in a Function?

Hi All,

i have this.asp page:

<script type="text/vbscript">
Function Body_Onload()
' create the object
Set obj = Server.CreateObject("UploadImage.cTest")
' use method of the object
Body_Onload = obj.cTestDelete
Set obj = Nothing
End Function
</script>

<html>
<body onload="Body_Onload()">
</body>
</html>

the this.asp gives an Error while running:
Line 4
Char 1
Error Object required 'Server'
Code 0
URL http://127.0.0.1/this/this.asp

my Question:
How to create a Server Object in a Function?

Nov 4 '06 #1
7 6189

"thisis" <he******@web.dewrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
Hi All,

i have this.asp page:

<script type="text/vbscript">
Function Body_Onload()
' create the object
Set obj = Server.CreateObject("UploadImage.cTest")
' use method of the object
Body_Onload = obj.cTestDelete
Set obj = Nothing
End Function
</script>

<html>
<body onload="Body_Onload()">
</body>
</html>

the this.asp gives an Error while running:
Line 4
Char 1
Error Object required 'Server'
Code 0
URL http://127.0.0.1/this/this.asp

my Question:
How to create a Server Object in a Function?
You can't call server-side code directly from client-side code. You'll need
to send an asynchronous http request from the browser to a server-side
script which can then make calls to Server.CreateObject. Some people call
it Ajax. Have a look here: http://www.w3schools.com/ajax/

--
Mike Brind
Nov 4 '06 #2

"Mike Brind" <pa*******@hotmail.comwrote in message
news:Oc**************@TK2MSFTNGP02.phx.gbl...
>
"thisis" <he******@web.dewrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
Hi All,

i have this.asp page:

<script type="text/vbscript">
Function Body_Onload()
' create the object
Set obj = Server.CreateObject("UploadImage.cTest")
' use method of the object
Body_Onload = obj.cTestDelete
Set obj = Nothing
End Function
</script>

<html>
<body onload="Body_Onload()">
</body>
</html>

the this.asp gives an Error while running:
Line 4
Char 1
Error Object required 'Server'
Code 0
URL http://127.0.0.1/this/this.asp

my Question:
How to create a Server Object in a Function?

You can't call server-side code directly from client-side code. You'll
need
to send an asynchronous http request from the browser to a server-side
script which can then make calls to Server.CreateObject. Some people call
it Ajax. Have a look here: http://www.w3schools.com/ajax/
Why does it need to asynchronous? I many cases this is undesirable.

Nov 5 '06 #3

"Anthony Jones" <An*@yadayadayada.comwrote in message
news:ek**************@TK2MSFTNGP03.phx.gbl...
>
"Mike Brind" <pa*******@hotmail.comwrote in message
news:Oc**************@TK2MSFTNGP02.phx.gbl...
>>
"thisis" <he******@web.dewrote in message
news:11**********************@m73g2000cwd.googleg roups.com...
Hi All,

i have this.asp page:

<script type="text/vbscript">
Function Body_Onload()
' create the object
Set obj = Server.CreateObject("UploadImage.cTest")
' use method of the object
Body_Onload = obj.cTestDelete
Set obj = Nothing
End Function
</script>

<html>
<body onload="Body_Onload()">
</body>
</html>

the this.asp gives an Error while running:
Line 4
Char 1
Error Object required 'Server'
Code 0
URL http://127.0.0.1/this/this.asp

my Question:
How to create a Server Object in a Function?

You can't call server-side code directly from client-side code. You'll
need
>to send an asynchronous http request from the browser to a server-side
script which can then make calls to Server.CreateObject. Some people
call
it Ajax. Have a look here: http://www.w3schools.com/ajax/

Why does it need to asynchronous? I many cases this is undesirable.
How do you mean?
Nov 5 '06 #4

Mike Brind wrote:
"Anthony Jones" <An*@yadayadayada.comwrote in message
news:ek**************@TK2MSFTNGP03.phx.gbl...

"Mike Brind" <pa*******@hotmail.comwrote in message
news:Oc**************@TK2MSFTNGP02.phx.gbl...
>
"thisis" <he******@web.dewrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
Hi All,

i have this.asp page:

<script type="text/vbscript">
Function Body_Onload()
' create the object
Set obj = Server.CreateObject("UploadImage.cTest")
' use method of the object
Body_Onload = obj.cTestDelete
Set obj = Nothing
End Function
</script>

<html>
<body onload="Body_Onload()">
</body>
</html>

the this.asp gives an Error while running:
Line 4
Char 1
Error Object required 'Server'
Code 0
URL http://127.0.0.1/this/this.asp

my Question:
How to create a Server Object in a Function?


You can't call server-side code directly from client-side code. You'll
need
to send an asynchronous http request from the browser to a server-side
script which can then make calls to Server.CreateObject. Some people
call
it Ajax. Have a look here: http://www.w3schools.com/ajax/
Why does it need to asynchronous? I many cases this is undesirable.

How do you mean?
Hi Mike Brind,

I looked at the link you gave, thanks.

I don't understand what's ajax got to do with my question in the start
of this thread:

How to create a Server Object in a Function using VBScript?

Nov 6 '06 #5
you are writing client side code you need to write asp server side code.

http://msconline.maconstate.edu/tutorials/default.aspx

"thisis" <he******@web.dewrote in message news:11**********************@m73g2000cwd.googlegr oups.com...
Hi All,

i have this.asp page:

<script type="text/vbscript">
Function Body_Onload()
' create the object
Set obj = Server.CreateObject("UploadImage.cTest")
' use method of the object
Body_Onload = obj.cTestDelete
Set obj = Nothing
End Function
</script>

<html>
<body onload="Body_Onload()">
</body>
</html>

the this.asp gives an Error while running:
Line 4
Char 1
Error Object required 'Server'
Code 0
URL http://127.0.0.1/this/this.asp

my Question:
How to create a Server Object in a Function?

Nov 6 '06 #6
"thisis" <he******@web.dewrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
>
Mike Brind wrote:
>"Anthony Jones" <An*@yadayadayada.comwrote in message
news:ek**************@TK2MSFTNGP03.phx.gbl...
>
"Mike Brind" <pa*******@hotmail.comwrote in message
news:Oc**************@TK2MSFTNGP02.phx.gbl...

"thisis" <he******@web.dewrote in message
news:11**********************@m73g2000cwd.googleg roups.com...
Hi All,

i have this.asp page:

<script type="text/vbscript">
Function Body_Onload()
' create the object
Set obj = Server.CreateObject("UploadImage.cTest")
' use method of the object
Body_Onload = obj.cTestDelete
Set obj = Nothing
End Function
</script>

<html>
<body onload="Body_Onload()">
</body>
</html>

the this.asp gives an Error while running:
Line 4
Char 1
Error Object required 'Server'
Code 0
URL http://127.0.0.1/this/this.asp

my Question:
How to create a Server Object in a Function?
You can't call server-side code directly from client-side code.
You'll
need
to send an asynchronous http request from the browser to a server-side
script which can then make calls to Server.CreateObject. Some people
call
it Ajax. Have a look here: http://www.w3schools.com/ajax/

Why does it need to asynchronous? I many cases this is undesirable.

How do you mean?

Hi Mike Brind,

I looked at the link you gave, thanks.

I don't understand what's ajax got to do with my question in the start
of this thread:

How to create a Server Object in a Function using VBScript?
Read the first line of my first response again: you can't call server-side
code directly from client-side code.

Your error occurs when you make a call in your function to
Server.CreateObject. Note: the big hint here is SERVER.CreateObject. ASP
code runs on the web server that the site is housed on, so you can only put
Server.CreateObject in ASP code. You can't put it in client side VBScript -
your Body_Onload() function, which runs on the user's browser - not the web
server.

The client side VBScript will only run after the page has finished executing
on the server and the response has been sent to the client. As far as the
web server is concerned, the page has finished and doesn't exist anymore.
Therefore, if you want to make use of server-side functionality once the
page has been assembled in the user's browser, you need to either get the
user to post the entire page back and respond to that event, or make use of
some event on the page to do a kind of partial post-back where the page
stays in the user's browser. This is where ajax comes in.

However, it seems to me pointless to make a call to server-side script when
the html body is still loading in the user's browser. Maybe someone else
will provide some obscure examples of when this is the right thing to do,
but at that point, there is no chance for user interaction, so you should
really move your Server.CreateObject to your ASP code in my view.

--
Mike Brind
Nov 6 '06 #7
Mike Brind wrote:

Why does it need to asynchronous? I many cases this is undesirable.

How do you mean?
In most cases further processing of subsequent code would be nonsense until
the result of the function has returned. It also leaves the UI live and
accepting other user events, handling these correctly whilst an outstanding
operation is in effect can be tricky.

I was wondering why this case would warrant it? It's difficult to see what
Thisis intends since the code appears to be doing some very strange things
to start with e.g.:-

Body_Onload = obj.cTestDelete

Nov 6 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: lkrubner | last post by:
I have a webserver through Rackspace. I create a domain. I create an FTP user. I upload some files. I create a database called testOfSetupScript and then I create a database user named setup. I...
7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
4
by: Miguel Dias Moura | last post by:
Hello, I created a datalist in an ASP.Net / VB page. I display the image and price of a few products. When a user clicks an image I want to load the page "detail.aspx?number=id" and send the...
6
by: Steve Richter | last post by:
I am getting error in a vbscript: ActiveX component cant create object: Excel.Application. The vbscript code is: Dim objExcel Set objExcel = CreateObject("Excel.Application") I am pretty...
10
by: Zack Sessions | last post by:
Has anyone tried to create a SQL7 view using the CREATE VIEW command and ADO.NET? If so, is there a trick in trapping a SQL error when trying to create the view? I have a VB.NET app that, amoung...
1
by: drk.kumar | last post by:
I have an implementation issue with WMI scripts to check the user machine processor. The implementation is working fine in the local machine (Windows XP operating system). It is throwing script...
5
by: Richard Lewis Haggard | last post by:
I am trying to create multi-dimensioned arrays in conventional ASP pages and pass these arrays as arguments to functions that are in a C# interop assembly. ASP complains because it doesn't...
3
by: Michael | last post by:
Hi. I have COM+ component installed on my XP. I have problem to create instance of it inside vbscript. How can I do it? The error I get is : ActiveX component can't create object. Thanks
1
by: TG | last post by:
Hi! I have an application in which I have some checkboxes and depending which ones are checked those columns will show in the datagridview from sql server or no. After that I have 2 buttons:...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.