Write Classes/com In Asp
I write classes in php, beans in jsp, what "modularity" does asp have? Can I write classes? Or "com" what can I do? which advantages exist with these paths: classes, com, etc.
View RepliesI write classes in php, beans in jsp, what "modularity" does asp have? Can I write classes? Or "com" what can I do? which advantages exist with these paths: classes, com, etc.
View RepliesWhen I write the code
Code:
Set a = new C1
Block of code
Set a = Nothing
Set b= new C2
Block of code
Set b = Nothing
The Class C2 doesn't work.
I've been searching for some information on the use of Classes in ASP, but
found very little information.
I found this http://www.daniweb.com/tutorials/tutorial19997.html .
Are there more information somewhere online?
For the majority of my work, I just use plain ASP. On the rare occasion that
I am doing something intensive that does require user interaction I might
create a COM component (ie where performance gain outweighs the overhead of
COM).
A simple Rule-of-Thumb. I imagine this is fairly common practice... (I hope
it is, at least).
However, I'm curious about VBScript Classes. I would have imagined that if a
page was complex enough to merit defining and creating your own
classes/objects, that COM would be appropriate...
In which case, when and how do people use VBScript Classes?
I am re-coding a VB application to be used on the web, some of which requires additional DB components for user registration etc. Usually I use ASP classes to manage the DB I/O stuff but I was wondering whether they are any benefits in having them as VB classes and compiled as dlls?
I like the idea of having the VB application as dlls, but using asp classes for the general functionality of the application. However, I don't wish to do this out of convience for myself.
one developer once told me that he doesn't use classes as there is a performance issue. is this true? the functions i'd be creating can easily go into an include file as a set of functions and not a class. so i'm not too sure about going ahead and encapsulating them into classes. has anyone got any input?
View Replies View RelatedI've been working in .NET for some time now and I don't remember specifically
how asp classes are cleaned up in classic asp. I've been put on a Classic
ASP project(ugh) and we're having some serious stability problems. Once we
reach a point of sustained CPU useage of over 80% IIS 6 restarts the w3wp.exe
process which of course terminates all sessions and resets the website.
I've
noticed that the previous developer has an include which creates a couple of
class objects in ASP. Not third party or "CreateObject" objects, but ASP
classes. This include is in A LOT of files and the classes not being
destroyed in any of them.
My question is could this be the problem? I seem to remember a problem with
ASP classes and not destroying them causing leaks of some sort. I need to
mention that the memory doesn't seem to be leaking but the CPU utilization
goes wacko as if ASP/IIS is corrupt. My environment is Windows 2k3 and IIS
6. The previous environment was Windows 2K and IIS5. Both environments had
the problem.
Before I go through these hundreds of files I was wondering if anyone
remember what the problem was with ASP classes not being destroyed.
I've always had problems getting my head around using collections and classes together. Separately, they seem like fairly simple subjects, but I'm getting muddled up when trying to use them together.
Can someone toss together a simple example of how I'd create my classes and collection? Code:
I'd like to create a class file for a shopping cart that I'm working on but I'm not sure about how to use the database with it.
Do I connect and open to the database inside the class or outside of the class and set the properties?
I'm thinking that if I open and close the database with say a getItem() method and I have 15 items to get, I'll be opening and closing a connection 15 times. Isn't that bad?
Assuming I create an object as below
<%
Dim objMainItem
Set objMainItem = New ItemContent
objMainItem.item_id = 1
objMainItem.Open()
%
and the class ItemContent creates a recordset based on the item_id passed in. Each item record contains the fields (header,label,content). I would like to reference the fields in the following format
<%= objMainItem.header %
Is there a way to use classes written in .NET in an ASP classic application? Maybe similair to using DLLs with Server.CreateObject? I want to write all our new classes using .NET with the intent of eventually changing the web application to ASP.NET.
I've tried Googling for the answer but I only get ASP.NET literature. Any suggestions for that problem?
Suppose if I am using two classes in my code Say C1 and C2 then is there some procedure or special way to use them one after another.
Set a = new C1
Block of code
Set a = Nothing
Set b= new C2
Block of code
Set b = Nothing
The Class C2 doesn't work. Any idea Why?
I'm currently new to OO programming with Classic ASP and have been stopped dead in my tracks on the issue of validation inside classes and if I should be doing things that way. I have been using a User class and it has methods such as Save(), Update() and Delete(). Particularly with the Update() method I'm unsure if I should be validating my form(s) within the class or on the actual edit.asp page that uses the Update() method?
I have two types of edit pages; one for Admin users and one for the My Account page. On the My Account page if the user wants to change their password they have to enter their current password, a new password and then their new password again to confirm .
If an Admin user is updating that same user's info they do not have to go through those steps and they can simple just change the password by typing it in. The point here is that there are two separate cases of validation rules on two separate pages that both use the Update() method. Do you validate your forms inside your classes or outside?
I'm trying to pass an array of classes through a function using vbscript and then access these the other side. for instance (in psuedo code)
redim Array()
for 0 to array end fill with data (these happen to be classes)
but not sure that should make any difference?!)
someFunction(array())
function someFunction(data)
response.write data(0).property
end function
which doesn't work although data.property does if I specify which part of the array I'm passing i.e. someFunction(array(1))
I've written two classes in ASP (vbscript). Basically I am attempting a form of data encapsulation. The classes are a "master" class and an "address" class. The address class basically wraps a recordset. I've attached the file. whenever I call the "move" method the recordset should be EOF since there is only 1 record in my streetaddress table. If I write out the value of of p_oRs.eof inside of the "move" method it returns true.
I have declared p_oRs as a public variable. But if I access it from a different method (or a property get/let) then the p_oRs recordset is no longer EOF the pointer is on the first and only record.
Say I have a few functions for accessing a database e.g. openDBConn, closeDBConn, openRs, closeRs, getRsAsArray, executeSql, getDbConnString etc
I could put these functions in to an include file "incDbHelper.asp" and include the file in any page that needs database functionality... or I could create a class "clsDbhelper.asp" which again I would include in any page that needs it. Now once the files have been included, to access the functions I could do: Code:
I've read that one shouldn't include ADO objects in the Global.asa for the sake of performance, but would user-defined classes cause the same kind of performance hit? Assuming that they wouldn't, is it possible to do it?
I can't seem to figure out how to include them, nor find any reference to it in msdn.
Is there a way to do this? Or should I create a slew of Session variables? Code:
I can't seem to get error handling to work from inside my classes. On the outside it works but on the inside it doesn't. Any thoughts?
if err.number <> 0 then response.write "errors" end if
I'm trying to catch all the errors as I go and I can't do that if it won't work on the inside of my classes.
I have 2 MS Access databases DB1.mdb and DB2.mdb.
In DB1.mdb there is a table named table1 and in DB2.mdb there is a table named table2.
How do I write query in ASP to write the records from table1 in DB1.mdb to table2 in DB2.mdb.
i am having a problem with ASP not doing the requestion action of Response.Write based on conditions of a code entered on a first page. The codes are below. I made the second page from template of another that yall helped me with and it aint working.. Code:
View Replies View RelatedWas curious if someone could help me out. I'm setting up a website and using Server side includes to make it easier for maintaining. I've got a contact form that will be included on several pages and I need to know from what page the forms is getting posted from. If I can figure out how to pass one value to a hidden field I can use the form as an include instead of hard coding the whole form into each page.
Ideally the value to be passed could be coded into each page then asp could pick it up and insert it into the hidden field. Any one point me in the right direction for accomplishing this. I don't have a clue about asp other than the basic include statement.
I select 'name' from the customer table.
Is it possible to write it into a cookie?
<%
Response.Cookies("customer")("firstname") = '" & objRecordset(NAME) & "'
%>
when I try to write the above using
<%
Response.Write (Request.Cookies("customer")("firstname"))
%>
i get the following ....
May i know isit can use asp to send an automail when customer fill up the registration form. i need to send a automail to his email verify the customer details. is it any free source code to write?
View Replies View RelatedI writing code that will create asp pages using the file system object.
<%
..
..
'other code here
Response.Write "<%sName=" & Var & "%>"
%>
How can I do this?
If my recordset is empty I want to write "Not Complete" and if there is
a value, I want to write the value. Can someone tell me what I am
doing wrong?
<%
If IsEmpty(rsa.Fields.Item("reclaima")) Then
Response.Write("Not Complete")
Else
Response.Write(rsa.Fields.Item("reclaima"))
End If
%>
Also tried....
<%
If rsa.Fields.Item("reclaima") = "" Then
Response.Write("Not Complete")
Else
Response.Write(rsa.Fields.Item("reclaima"))
End If
%>
Since ASP server scripts use VBScript by default, does it mean it is
redundant to put the following in ASP page? Then when do we need to use
this? In client-side VBScript?
I have a script in ASP:
If strReport = "OrderDetail" then
strReport1 = strReport & ".rpt"
End If
If strReport1 <> "" Then
strReport1 = strReport & Year(strPeriod) & ".rpt"
End If
Now based on the kind of value in strReport1, I would like to do 2 different set of work.... Like for instance,
If strReport = "OrderDetail" then
call SubReportDB
End If
If strReport1 <> "" Then
Call SubOrderDetail
End If
Is that the right syntax?
While doing a response.Write,
I would like to display the text as array item wrapped in quotes. How can I do that?
I write the code as:
'Now get all the sub-reports names to pass the log-on information
For i = 0 to UBound(aSubRpt,2)
Response.Write "webSource0.AddParameter " & u0 & " & " & aSubRpt(c_SRName,i) & ", " & dbd & "<br>"
Response.Write "webSource0.AddParameter " & p0 & " & " & aSubRpt(c_SRName,i) & ", " & dbc & "<br>"
'Response.Write aSubRpt(c_SRName,i) & "<br>"
Next
While seeing the results in the browser, I would like to see
"aSubRpt(c_SRName,i)"
which is primarily
"reportname"
How can I wrap the text in double quotes within a response.Write?
I want to be able to write a gif in my ASP app. Not even sure if it is possible with response.write. I want to replace the 'Member Log In' text with XXX.gif, and still have it linked to login.asp....
View Replies View RelatedI am trying to retrieve info from database and display it in the form. The problem I having is when I try to change the info in the form, it is not changing and I don't know why.
table.fieldname = payroll
Code:
payroll = rs("payroll")
If payroll = "something" Then
payroll = "Some Payroll"
End If
In the form table:
<input type="text" name="payroll" value=<%response.write(payroll)%>>
I want "Some Payroll" to be displayed in the form instead of "Something".
I need to put this whole line into a response.write statement:
field delimiter = """
Code:
<%
username = Session("username")
if ("" = username) Then
Response.redirect "login.asp"
response.Write("Sorry, you are not logged in.")
response.End
End if
%>
How do i write that Sorry, you are not logged in ... to the login.asp?
I've tried using a FSO to write to it directly. I've even managed to write a script for windows scripting host and invoke it from ASP, using standard output redirection (">") to redirect output to a file with no problems.
However, I can't seem to send writes to LPT2: from ASP, even through the other script.
It works perfectly fine if I invoke the WSH script at a command prompt using precisely the same command line, but when I do it from inside an ASP page, I get nothing.
Are there some permissions for the port I have to set or some such? I honestly have no idea how to get it to work.
If it is relevant, LPT2: is a mapped port for a network printer.
Yes, this is related to my previous thread, but I'm down to a much, much more specific problem.