| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
||||
|
||||
|
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> </td><td> </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> </td><td> </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>" %> |
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > Free State Management ASP component |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|