473,387 Members | 1,863 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,387 software developers and data experts.

Problem with ASP class which does not pass its variables

I am fixing a client's Web site and for some reason an ASP class does
not want to use the variables it retrieves when it initialiases.

This is an excerpt of the class and it is enough to show what is not
working correctly:
------
Class clsAd
private pintMyData1
private pintMyData2
private pintMyData3

Private Sub class_Initialize()
(... creates some objects)
GetRequestData()
End Sub

Private Sub Class_Terminate()
(... kills some objects)
End Sub

Private Sub GetRequestData()
pintMyData1 = request("MyData1")
pintMyData2 = request("MyData2")
pintMyData3 = request("MyData3")
End Sub

Public Function AdList()
(retrieves a list from an SQL database use MyData1, etc...)
End Function

End Class

Dim AD
Set AD = new clsAd
------

First, MyPage.asp will include the class:

<!--#include virtual="/inc/clsAd.asp"-->

Then this code is supposed to retrieve a list of ads:
MyArray = AD.AdList()

The problem is that the variables are not retrieved properly and
therefore the list always includes the entire list (the Stored
Procedures functions this way).

If I insert "response.write pintMyData1" inside of the class, either
inside of GetRequestData() or of class_Initialize(), then the data will
show.

If I insert "response.write pintMyData1" inside of the parent
MyPage.asp, after the include, it does not show the data. If I insert
it inside of Public Function AdList(), it does not show either.

What is wrong in this code? I wonder if all the "private" should not be
switched to "public"? Or should I look into something else?

Thanks a lot in advance!

Jul 27 '05 #1
3 1780
1. Do not use Request("name"). Specify what collection you're pulling
from, eg. Request.Form("name")
2. I suggest modifying your class and making public properties for
assigning those private values instead of pulling them from a request
object.
3. In regard to "> If I insert "response.write pintMyData1" inside of the
parent> MyPage.asp," this is expected. pingMyData1 is a private variable
available only to the class. Try this version:
Class clsAd

private _pintMyData1
private _pintMyData2
private _pintMyData3
Private Sub class_Initialize()
(... creates some objects)
_pintMyData1 = "some default value" 'optional
_pintMyData2 = "some default value" 'optional
_pintMyData3 = "some default value" 'optional
End Sub

Public Property Set pingMyData1(s)
_pintMyData1 = s
End Property

Private Sub Class_Terminate()
(... kills some objects)
End Sub

Public Function AdList()
(retrieves a list from an SQL database use MyData1, etc...)
End Function
End Class

Dim AD
Set AD = new clsAD
clsAD.pintMyData1 = "some value"
clsAD.pintMyData2 = "some value"
clsAD.pintMyData3 = "some value"

MyArray = clsAd.AdList()
Ray at work
<ni****@yahoo.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
I am fixing a client's Web site and for some reason an ASP class does
not want to use the variables it retrieves when it initialiases.

This is an excerpt of the class and it is enough to show what is not
working correctly:
------
Class clsAd
private pintMyData1
private pintMyData2
private pintMyData3

Private Sub class_Initialize()
(... creates some objects)
GetRequestData()
End Sub

Private Sub Class_Terminate()
(... kills some objects)
End Sub

Private Sub GetRequestData()
pintMyData1 = request("MyData1")
pintMyData2 = request("MyData2")
pintMyData3 = request("MyData3")
End Sub

Public Function AdList()
(retrieves a list from an SQL database use MyData1, etc...)
End Function

End Class

Dim AD
Set AD = new clsAd
------

First, MyPage.asp will include the class:

<!--#include virtual="/inc/clsAd.asp"-->

Then this code is supposed to retrieve a list of ads:
MyArray = AD.AdList()

The problem is that the variables are not retrieved properly and
therefore the list always includes the entire list (the Stored
Procedures functions this way).

If I insert "response.write pintMyData1" inside of the class, either
inside of GetRequestData() or of class_Initialize(), then the data will
show.

If I insert "response.write pintMyData1" inside of the parent
MyPage.asp, after the include, it does not show the data. If I insert
it inside of Public Function AdList(), it does not show either.

What is wrong in this code? I wonder if all the "private" should not be
switched to "public"? Or should I look into something else?

Thanks a lot in advance!

Jul 27 '05 #2
Thanks. Ok for the private variable kept inside the class, but even when I
try to print it from inside the class itself (AdList function) the value
does not show.

I already have that code as well, I forgot to mention:

Public Property Set pingMyData1(s)
_pintMyData1 = s
End Property
"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:uk*************@TK2MSFTNGP14.phx.gbl...
1. Do not use Request("name"). Specify what collection you're pulling
from, eg. Request.Form("name")
2. I suggest modifying your class and making public properties for
assigning those private values instead of pulling them from a request
object.
3. In regard to "> If I insert "response.write pintMyData1" inside of the
parent> MyPage.asp," this is expected. pingMyData1 is a private variable
available only to the class. Try this version:
Class clsAd

private _pintMyData1
private _pintMyData2
private _pintMyData3
Private Sub class_Initialize()
(... creates some objects)
_pintMyData1 = "some default value" 'optional
_pintMyData2 = "some default value" 'optional
_pintMyData3 = "some default value" 'optional
End Sub

Public Property Set pingMyData1(s)
_pintMyData1 = s
End Property

Private Sub Class_Terminate()
(... kills some objects)
End Sub

Public Function AdList()
(retrieves a list from an SQL database use MyData1, etc...)
End Function
End Class

Dim AD
Set AD = new clsAD
clsAD.pintMyData1 = "some value"
clsAD.pintMyData2 = "some value"
clsAD.pintMyData3 = "some value"

MyArray = clsAd.AdList()
Ray at work
<ni****@yahoo.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
I am fixing a client's Web site and for some reason an ASP class does
not want to use the variables it retrieves when it initialiases.

This is an excerpt of the class and it is enough to show what is not
working correctly:
------
Class clsAd
private pintMyData1
private pintMyData2
private pintMyData3

Private Sub class_Initialize()
(... creates some objects)
GetRequestData()
End Sub

Private Sub Class_Terminate()
(... kills some objects)
End Sub

Private Sub GetRequestData()
pintMyData1 = request("MyData1")
pintMyData2 = request("MyData2")
pintMyData3 = request("MyData3")
End Sub

Public Function AdList()
(retrieves a list from an SQL database use MyData1, etc...)
End Function

End Class

Dim AD
Set AD = new clsAd
------

First, MyPage.asp will include the class:

<!--#include virtual="/inc/clsAd.asp"-->

Then this code is supposed to retrieve a list of ads:
MyArray = AD.AdList()

The problem is that the variables are not retrieved properly and
therefore the list always includes the entire list (the Stored
Procedures functions this way).

If I insert "response.write pintMyData1" inside of the class, either
inside of GetRequestData() or of class_Initialize(), then the data will
show.

If I insert "response.write pintMyData1" inside of the parent
MyPage.asp, after the include, it does not show the data. If I insert
it inside of Public Function AdList(), it does not show either.

What is wrong in this code? I wonder if all the "private" should not be
switched to "public"? Or should I look into something else?

Thanks a lot in advance!


Jul 27 '05 #3

"Nicolas Verhaeghe" <no***********@yahoo.com_nospam> wrote in message
news:42***********************@news.twtelecom.net. ..
Thanks. Ok for the private variable kept inside the class, but even when I
try to print it from inside the class itself (AdList function) the value
does not show.

Perhaps that is because Request("MyData1") doesn't have a value. First,
change it to Request.FOrm, Querystring, or whatever collection you're
pulling from. Then try. If that doesn't work, make sure your item actually
does have a value by trying something like:

For Each hamsandwich in Request.Form
Response.Write hamsandwich & " = " & Request.Form(hamsandwich) & "<br
/>"
Next

Ray at work
Jul 27 '05 #4

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

Similar topics

2
by: Marc | last post by:
Hi all, I was using Tkinter.IntVar() to store values from a large list of parts that I pulled from a list. This is the code to initialize the instances: def initVariables(self): self.e =...
5
by: Chris | last post by:
Hi, I don't get the difference between a struct and a class ! ok, I know that a struct is a value type, the other a reference type, I understand the technical differences between both, but...
9
by: Brian Henry | last post by:
If i inherite a queue class into my class, and do an override of the enqueue member, how would i then go about actually doing an enqueue of an item? I am a little confused on this one... does over...
14
by: Derek Basch | last post by:
This one has always bugged me. Is it better to just slap a "self" in front of any variable that will be used by more than one class method or should I pass around variable between the methods? ...
5
by: AlexVN | last post by:
Hi, I would like to know if someone investigated the method of creating classes dynamically depending on the name. I do not like a lot of ifs and I suppose that something like...
5
by: H J van Rooyen | last post by:
Hi, I am struggling to get the pack method to do what I intend. I am trying to display user input in a seperate window, along with a little description of the field, something like this: ...
5
by: Slant | last post by:
Here's a question that most will have different answers to. I'm just dying to find a solution that seems halfway automated!! There really are two seperate issues which might be answered by the...
37
by: minkoo.seo | last post by:
Hi. I've got a question on the differences and how to define static and class variables. AFAIK, class methods are the ones which receives the class itself as an argument, while static methods...
5
by: tshad | last post by:
In VS 2003, I am setting up an abstract class that is setting up classes for each datatype of VB.Net (as well as C#). I am trying to set it up so that most of the work is done in the Abstract...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.