| re: Problem with ASP class which does not pass its variables
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:uka4jQrkFHA.764@TK2MSFTNGP14.phx.gbl...[color=blue]
> 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
>
>
> <nicver@yahoo.com> wrote in message
> news:1122449623.594282.27880@o13g2000cwo.googlegro ups.com...[color=green]
>> 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!
>>[/color]
>
>[/color] |