Portal Engine Questions on portal engine and web parts.
Version 4.x > Portal Engine > Multiple Paging Bizform View modes: 
User avatar
Member
Member
tspring-allegra - 10/11/2010 6:39:09 AM
   
Multiple Paging Bizform
Hi

I'm trying to create a multi-page bizform but i'm having a few problems getting started.

I found a previous post about it http://devnet.kentico.com/Forums.aspx?forumid=43&threadid=7325 but seam to be failing even at the first section.

I've created all the forms, copied/cloned the webpart, and added a "Next button".

But how do I use the Next button to change the form on the page to one of the Alternative Forms?

I have to following code on the button:

protected void Button1_Click(object sender, EventArgs e)
{
viewBiz.AlternativeFormFullName = "BizForm.MyBizForm.MyBizForm_Alternative1";
viewBiz.BasicForm.StopProcessing = true;
}

but this just refreshes the page with the original form.

Maybe i'm going wrong in thinking it would be this simple.

Does anyone have any working code or experience in this?

I can get the insert and save working fine via the button using the API (http://devnet.kentico.com/docs/devguide/index.html?bizforms_api.htm).
It's just changing the form once clicking "Next" that i'm having problems with.

Using the code above on the OnAfterSave event doesnt seam to work either!

Thanks,
Tim

User avatar
Member
Member
tspring-allegra - 10/15/2010 6:19:09 AM
   
RE:Multiple Paging Bizform
Can anyone help or give some advice? I've still not managed to get this working, even after reading though all the documentation and forum topics.

Basically all I need to figure out is how you dynamically change a bizforms layout to one of its alternative form layouts via a button click action.

Thanks,
Tim

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 10/18/2010 6:31:13 AM
   
RE:Multiple Paging Bizform
Hi,

Could you please try to use following code:

protected void Next_Click(object sender, EventArgs e)
{ //ClassName.AlternativeFormName
viewBiz.AlternativeFormFullName = "BizForm.name_of_biz_form.name_of_alternative_form";
viewBiz.BasicForm.SaveData("");
}


If you click the next button, defined alternative form will be displayed using this method.

Best regards,
Ivana Tomanickova

User avatar
Member
Member
tspring-allegra - 10/18/2010 8:21:34 AM
   
RE:Multiple Paging Bizform
Thanks for that, it worked great. The only trouble I have now is trying to make it submit onto a third page. I tried the following code:


protected void Button1_Click(object sender, EventArgs e)
{
if (viewBiz.AlternativeFormFullName=="") {
viewBiz.AlternativeFormFullName = "BizForm.name_of_biz_form.name_of_alternative_form1";
viewBiz.BasicForm.SaveData("");
viewBiz.BasicForm.StopProcessing = true;
}

if (viewBiz.AlternativeFormFullName=="BizForm.name_of_biz_form.name_of_alternative_form1") {
viewBiz.AlternativeFormFullName = "BizForm.name_of_biz_form.name_of_alternative_form2";
viewBiz.BasicForm.SaveData("");
viewBiz.BasicForm.StopProcessing = true;
}


The first section works fine in loading the first alternative form after clicking Next from the basic form. But when I try to click Next again it simple reloads the first alt-form and not the second alt-form. It seams that after the first Next click it's not fully setting the AlternativeFormFullName property, and that the second Next click If statement still reads this value is being blank so it doesnt load the second alt-form.

How can I check what form is currently displayed on the screen so I can set the following page form on the button click event...if that makes sense?

Thanks,
Tim

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 10/19/2010 8:42:52 AM
   
RE:Multiple Paging Bizform
Hi,

you can modify the code behind of cloned bizform webpart following way:

1. Replace orginal SetupControl() method with:

protected void SetupControl()
{
if (this.StopProcessing)
{
// Do nothing
viewBiz.StopProcessing = true;
}
else
{
// Set BizForm properties
viewBiz.FormName = this.BizFormName;
viewBiz.SiteName = this.SiteName;
viewBiz.UseColonBehindLabel = this.UseColonBehindLabel;


if (!QueryHelper.Contains("step"))
{
viewBiz.AlternativeFormFullName = this.AlternativeFormName;
}
else
{
switch (QueryHelper.GetString("step", "2"))
{
case "2": viewBiz.AlternativeFormFullName = "BizForm.steps.second";
break;
case "3": viewBiz.AlternativeFormFullName = "BizForm.steps.third";
break;
default: viewBiz.AlternativeFormFullName = this.AlternativeFormName;
break;
}
}

if (QueryHelper.GetInteger("ItemID", 0) > 0)
{
viewBiz.ItemID = QueryHelper.GetInteger("ItemID", 0);
viewBiz.FormMode = FormModeEnum.Update;
}


viewBiz.ValidationErrorMessage = this.ValidationErrorMessage;

// Set the live site context
if (viewBiz.BasicForm != null)
{
viewBiz.BasicForm.ControlContext.ContextName = CMS.SiteProvider.ControlContext.LIVE_SITE;
viewBiz.BasicForm.SubmitButton.Visible = false;
}
viewBiz.BasicForm.OnAfterSave += new CMS.FormControls.BasicForm.OnAfterSaveEventHandler(BasicForm_OnAfterSave);
}
}


2. Add following two methods:


// do not forget to add following line into ascx file
// <asp:Button ID="Next" runat="server" Text="Next" onclick="Next_Click" />
//
protected void Next_Click(object sender, EventArgs e)
{
viewBiz.BasicForm.SaveData("whatever_this_will_not_be_used");
}


void BasicForm_OnAfterSave()
{
int stepID = QueryHelper.GetInteger("step", 0);

if (stepID == 0)
{
string url = UrlHelper.AddParameterToUrl(UrlHelper.CurrentURL, "step", "2");
url = UrlHelper.AddParameterToUrl(url, "ItemID", viewBiz.ItemID.ToString());
UrlHelper.Redirect(url);
}
else if (stepID >= 2)
{

if (stepID == 3)
{
UrlHelper.Redirect(UrlHelper.ResolveUrl("~/thank-you.aspx"));
}

string url = UrlHelper.AddParameterToUrl(UrlHelper.CurrentURL, "step", (++stepID).ToString());
url = UrlHelper.AddParameterToUrl(url, "ItemID", viewBiz.ItemID.ToString());
UrlHelper.Redirect(url);
}
}


This example however allows attacker to update particular BizForm record if he knows the ItemID of your Bizform.

Best regards,
Ivana Tomanickova

User avatar
Member
Member
tspring-allegra - 11/2/2010 7:43:31 AM
   
RE:Multiple Paging Bizform
Hi

Thanks for the help!

I finally implemented the code, the only changes I made were instead of passing the ItemID in the URL. I stored the ItemID encrypted in a cookie during the OnAfterSave method, as I was already storing some simple form data that way (i.e. name, email etc) to pass into a custom user registration page after the bizform is fully submitted.

I also added some form field checking in the Next_Click method, so I could do some validation before saving the form data.

Worked perfectly...thanks again!

Tim

User avatar
Member
Member
steven4733-gmail - 1/10/2012 3:47:37 PM
   
RE:Multiple Paging Bizform
In SetupControl method, I copied your code but why the VS report error says that "The type name 'OnAfterSaveEventHandler' does not exist in the type 'CMS.FormControls.BasicForm'"?

I use Kentico 6.0

User avatar
Member
Member
evab-kentico - 1/11/2012 7:31:54 AM
   
RE:Multiple Paging Bizform
Hi,

in the 6.0 version is definition of event handler following:


viewBiz.BasicForm.OnAfterSave += new EventHandler(BasicForm_OnAfterSave);

void BasicForm_OnAfterSave(object sender, EventArgs e)
{
//TODO: implementation
}


The easiest way how to find out definition is type:

viewBiz.BasicForm.OnAfterSave += and click TAB and then again TAB - the code will be generated automatically.

Best regards,
Ivana Tomanickova