Free State Management ASP componentBiju 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>" %> |
|
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
More ASP Code Articles More By aspfree developerWorks - FREE Tools! | You'll get answers to many questions and more from David Barnes, Lead Evangelist for IBM Emerging Internet Technologies. David will discuss aspects of Web 2.0 that bring value to corporations, academia, and government. He'll also discuss IBM's vision around Web 2.0, including the importance of remixability and consumability. The discussion will culminate with examples of various IBM Software Group solutions you can use to get ahead of the Web 2.0 adoption curve. FREE! Go There Now!
| | | | Achieving true agility is a never-ending effort. We will showcase how you can become agile incrementally, a few practices at the time.Which practices should any agile team strive to adopt? What additional practices should you consider based on your needs to scale? Adopting practices are however made much easier with the right tool support. What about if your tools adapt to your practices? We will take a look at how the Jazz technology can be leveraged to make your process change the behavior of your tools. FREE! Go There Now!
| | | | Effective governance for lean development isn’t about command and control. Instead, the focus is on enabling the right behaviors and practices through collaborative and supportive techniques. Hear from Scott Ambler on how it is far more effective to motivate people to do the right thing than it is to force them to do so. Learn how to form a lightweight, collaboration-based framework that reflects the realities of modern IT organizations. FREE! Go There Now!
| | | | Visit IBM developerWorks to download IBM DB2 Express-C 9.5, a no-charge version of DB2 Express 9 database server. DB2 Express-C offers the same core data server base features as other DB2 Express editions and provides a solid base to build and deploy applications developed using C/C++, Java, .NET, PHP, and other programming languages. FREE! Go There Now!
| | | | Manage, govern, and share services across your organization by using WebSphere Service Registry and Repository. Follow the hands-on exercises to learn how to navigate the Web interface to publish, find, reuse, and update services. FREE! Go There Now!
| | | | Secure your Web applications with IBM Rational AppScan Standard Edition V7.7, previously known as Watchfire AppScan. This Web application security testing tool automates vulnerability assessments and scans and tests for common Web application vulnerabilities. Visit IBM developerWorks to download a free trial of IBM Rational AppScan Standard Edition V7.7. FREE! Go There Now!
| | | | As systems increase in complexity, communication between systems and software teams becomes more and more difficult. Now, there’s a way to improve product quality and communication.<br />Read the “Model Driven Systems Development” white paper to see how. Also included in this kit are more educational white papers, customer examples, tutorials, informative Webcasts, and best practices for designing, building and managing systems.<br /> FREE! Go There Now!
| | | | Get a free trial download of the latest version of IBM Rational Performance Tester V7.0.1, a load and performance testing solution for teams concerned about the scalability of their Web-based applications. Combining multiple ease-of-use features with granular detail, Rational Performance Tester simplifies the test-creation, load-generation and data-collection processes that help teams ensure the ability of their applications to accommodate required user loads. FREE! Go There Now!
| | | | Attend this launch webcast with Scott Hebner, Vice President of IBM Rational Marketing and Strategy, where he will overview Rational’s new offerings and programs to help customers accelerate software innovation on System z. He will discuss how these solutions help organizations extend their core business processes toward modern architectures such as SOA and web technologies to deliver business improvements that stand the test of time. FREE! Go There Now!
| | | | The Eclipse community is constantly working to extend Eclipse's functionality. In this webcast, learn about some of the most important and feature-rich projects under development. From multi-language support to plug-in development, tune in to see what Eclipse is capable of now. FREE! Go There Now!
| | | | All FREE IBM® developerWorks Tools! | |