SunQuest
 
           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:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old February 5th, 2004, 03:16 PM
Rich's Avatar
Rich Rich is offline
Administrator
Developer Shed Admin.
 
Join Date: Sep 2003
Location: Fort Lauderdale, FL
Posts: 151 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 37 sec
Reputation Power: 10
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


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





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway