Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old February 5th, 2004, 04:16 PM
Rich's Avatar
Rich Rich is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Fort Lauderdale, FL
Posts: 152 Rich User rank is Sergeant (500 - 2000 Reputation Level)Rich User rank is Sergeant (500 - 2000 Reputation Level)Rich User rank is Sergeant (500 - 2000 Reputation Level)Rich User rank is Sergeant (500 - 2000 Reputation Level)Rich User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 11 h 49 m 15 sec
Reputation Power: 22
Free State Management ASP component

Biju Francis sent ASPFree code that does not use any of the known methods of State management in ASP. What it is using is a Component which maintains the of Controls and recordsets. This is a very handy component to experiment with! Thanks Biju!


<%@ Language=VBScript %>
<object id ='objContainer' progid='DataCom.DataContainer' runat='server'></object>
<%
'Create an Object of Component DataCom.DataContainer

Dim rsData
'----------------------------------------------------------------------------------

'This If Condition Checks if the user is comning from some other page
If trim(Request.QueryString("FromPage"))<>"" then
'if the user comes from some other page back to this page
'the values of the controls are retreived
Set rsData=objContainer.GetControlValues (Session.SessionID ,"Page1Container")
'Once the Values are Retreived the DataContainer is Killed
objContainer.KillDataContainer Session.SessionID,"Page1Container"
End If

'----------------------------------------------------------------------------------

'This function takes one Parameter i.e. the ControlName and
'returns a Value for that Control if it exist.
'This Function is Called below where the Value for the textboxes are
'e.g. value = fnControlValue("txtFirstName")

Function fnControlValue(byval ctrlname)
if isobject(rsData) then
rsdata.Movefirst
rsdata.find "ControlName like '" & ctrlname & "'"
if rsdata.eof then
fnControlValue = ""
else
if isnull(rsdata("ControlValue")) then
fnControlValue = ""
else
fnControlValue = rsData("ControlValue")
end if
end if
else
fnControlValue = ""
end if
End function

'-----------------------------------------------------------------------------------

Response.Write "<html>" _
& "<body>" _
& "<Form name ='Page1' method ='Post'>" _
& "<table border='0' cellpadding='0' width='75%'>" _
& "<tr>" _
& "<td colspan='2'><strong>Enter Details</strong></td>" _
& "</tr>" _
& "<tr>" _
& "<td>&nbsp;</td><td>&nbsp;</td>" _
& "</tr>" _
& "<tr>" _
& "<td>First Name</td><td><input type='text' name='txtFirstName' value ='" & server.HTMLEncode(fnControlValue("txtFirstName")) & "'></td>" _
& "</tr>" _
& "<tr><td>Last Name</td><td><input type='text' name='txtLastName' value ='" & server.HTMLEncode(fnControlValue("txtLastName")) & "'></td>" _
& "</tr>" _
& "<tr><td>Title</td><td><input type='text' name='txtTitle' value ='" & server.HTMLEncode(fnControlValue("txtTitle")) & "'></td>" _
& "</tr>" _
& "<tr><td>Email Id</td><td><input type='text' name='txtEmail' value ='" & fnControlValue("txtEmail") & "'></td>" _
& "</tr>" _
& "<tr><td>&nbsp;</td><td>&nbsp;</td></tr>" _
& "<tr><td></td>" _
& "<td><input type = 'submit' name = 'cmdSubmit' Value = 'Go to Page2'></td>" _
& "</tr>" _
& "</table>" _
& "</body>" _
& "</html>"

%>

<SCRIPT ID=clientEventHandlersVBS LANGUAGE=vbscript>
<!--

Sub cmdSubmit_OnClick
Page1.action = "Page2.asp"
Page1.submit
End sub

-->
</SCRIPT>


Page 2 of the sample

<%@ language=VBScript %>
<object id ='objContainer' progid='DataCom.DataContainer' runat='server'></object>
<%
'Create an Object of Component DataCom.DataContainer

Dim rsData

'This Method creates a Container to Store the Control Values
set rsData = objContainer.CreateDataContainer
'Loops through the Form Collection
For each name in Request.Form
rsData.AddNew
rsData("ControlName") = name
rsData("ControlValue") = Request.Form(name)
Next
rsData.UpdateBatch
'This Method set the Values of the Controls to the Data Container
objContainer.SetControlValues session.sessionid,"Page1Container",rsData

Response.Write "<a href='Page1.asp?FromPage=Page2'>Back to Page1</a>"
%>

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingCode Bank > Free State Management ASP component


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump





 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek