Load BizForm in a Custom Web part

Tracey Penberthy asked on June 5, 2017 14:19

Hi

I am trying to load a bizform in a custom web part using the following:

<%@ Register Src="~/CMSWebParts/BizForms/bizform.ascx" TagPrefix="cms" TagName="BizForm" %>

<cms:BizForm ID="cms_CustomBizForm"
    SiteName="TraceysSite"
    BizFormName="TraceyTestForm" 
    AlternativeFormName="BizForm.TraceyTestForm.TraceyTestForm1"
    UseColonBehindLabel="false" 
    Visible="true" 
    runat="server" />

The form is not rendering on the page I just get an empty div

<div id="p_lt_ctl03_pageplaceholder_p_lt_ctl01_ContextNavigation_CustomBizFormID_viewBiz">
</div>

I am not getting any errors in the event log.

Am I missing something in my markup?

Many Thanks Tracey

Correct Answer

Anton Grekhovodov answered on June 5, 2017 16:25

You should use CMS.OnlineForms.Web.UI.BizForm control instead of webpart. Look example here CMS\CMSWebParts\BizForms\bizform.ascx

0 votesVote for this answer Unmark Correct answer

Recent Answers


Anton Grekhovodov answered on June 5, 2017 14:38 (last edited on June 5, 2017 14:39)

Hi,
There is a similar question How to programmatically add Bizforms on custom web part. I guess you missed IsLiveSite="true" attribute and you need to populate ContorlContext property.
I hope it helps.

0 votesVote for this answer Mark as a Correct answer

Tracey Penberthy answered on June 5, 2017 15:27

Thanks Anton

I did see that post and have set IsLiveSite to true but I cannot set ContextName (cms_CustomBizForm.ControlContext.ContextName) as it says that ControlContext is a readonly string.

I tried cms_CustomBizForm.SetContext(); in SetUpControl() but that doesn't help.

0 votesVote for this answer Mark as a Correct answer

Tracey Penberthy answered on June 5, 2017 16:38

Thanks Anton

That has worked for me.

Really appreciate the help.

Tracey

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on June 5, 2017 16:45

It's recommended to use the user controls when creating a custom webpart vs. other webparts. This is because of the page lifecycle and how it is different for webparts vs. user controls.

0 votesVote for this answer Mark as a Correct answer

Tracey Penberthy answered on June 5, 2017 16:48

Good to know, thanks Brenden

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.