Hello,
I am new to Kentico, and was wondering if somebody could help point me in the right direction.
I have a set of three forms that are set up in a hierarchy, and I would like to pass some information from form to form. In the first form the user enters some data. To make it simple I will just say it is their name and DOB. Also, I am generating a GUID for the user in the first form. Here is the code to generate the GUID (“ID” is the name of the GUID form element):
//Generate GUID
//.ascx markup
OnOnBeforeSave="viewBiz_SetGUID"
//code behind
protected void viewBiz_SetGUID(){
string GUID = Guid.NewGuid().ToString();
if (this.viewBiz.BasicForm.FieldControls.ContainsKey("ID")){
this.viewBiz.BasicForm.DataRow["ID"] = GUID;
}
}
Once the 1st form is submitted, a link to the 2nd form will be sent to another party’s email. This link will contain a query string with the user’s GUID.
The name and DOB of the user have to be passed to the 2nd form to be viewed by the other party, who also need to enter some new info. I would like to use the GUID in the query string to identify the record with which to populate the “Name” and “DOB” fields of the second form. Here is the code for pulling the query string from the URL:
public override void OnContentLoaded(){
base.OnContentLoaded();
SetupControl();
Control ctrl = Form2.BasicForm.FindControl("ID");
if ((ctrl != null) && (ctrl is TextBox)){
if ((Request.QueryString["GUID"] != null) && (Request.QueryString["GUID"] != "")){
((ID)ctrl).Text = Request.QueryString["GUID"];
}
}
}
Also, here is my current (incomplete) code for pulling the user’s name and DOB data from the first form into the second form:
CMS.TreeEngine.TreeProvider tree = new CMS.TreeEngine.TreeProvider();
Control nameCtrl = Form2.BasicForm.FindControl("Name");
CMS.TreeEngine.TreeNode nameNode = tree.SelectSingleNode(Name).Parent;
((Name)nameCtrl).Text = nameNode.GetValue("Name");
Control dobCtrl = Form2.BasicForm.FindControl("DOB");
CMS.TreeEngine.TreeNode dobNode = tree.SelectSingleNode(DOB).Parent;
((DOB)dobCtrl).Text = dobNode.GetValue("DOB");
My problem is that I can’t find a way to specify which record to pull this data from; I would need to search through all the records from the 1st form to find a GUID that matched the query string, and say pull the information from that record. Is there a way that I can do this?
Any other comments or tips are welcome as well
Thanks