This explanation assumes knowledge of ASP.NET and provides a basic RedBack example. This example first connects to a uObject RBO (Customer) and then preserves the RBO Handle. It then does a read to get some state from the RBO Server. We then re-use the object and open the Employee RBO. So that the state is not replaced in that object. The CustomerMaint RBO is then re-openned, but this time we use the object handle not the class name. This tells RedPages to re-use the current RBO instance and refresh the state. The data displayed on the page is therefore from the original state.
string CustId = ""; string Name = ""; private void Page_Load(object sender, System.EventArgs e) { string custHandle; string sessionID; REDPAGESLib.RedObject obj = new REDPAGESLib.RedObject(); REDPAGESLib.RedProperty prop; try { // open CustomerMaint RBO obj.Open2("rbexamples", "EXMOD:CustomerMaint", "", "", ""); //preserve the handle and session id custHandle = obj.RBOHandle; sessionID = obj.sessionid; //now do a read using customer 1 prop = (REDPAGESLib.RedProperty)obj.Property("CustId"); prop.Value = "1"; obj.CallMethod("ReadData"); obj.Close(); //now re-use the object on Employee RBO obj.Open2("rbexamples", "EXMOD:Employee", "", "", sessionID); obj.Close(); // now re-open Customer using stored handle. We will then get the state for the RBO obj.Open2("rbexamples", custHandle,"","",sessionID); // get data from refreshed object from backend without calling method! prop = (REDPAGESLib.RedProperty)obj.Property("CustId"); CustId = prop.Value; prop = (REDPAGESLib.RedProperty)obj.Property("Name"); Name = prop.Value; // confusing? the point is to show that you can save off the handle to a stateful object // and bring back that stateful object's contents with an open command without // having to call a method to read the data again } catch (Exception ex) { throw ex; } // the form should now display data for Customer 1 } See the rbexamplesnetcsharp directory to review the page's entire source code. |