0

Using Kentico 7, I have a cms form on the aspx page like so:

<cms:CMSForm runat="server" ID="cmsFormCreate"
    FormMode="Insert" ShowOkButton="false"
    ParentNodeID='<%# documentsFolderNodeID %>'
/>

On the backend, I'm setting the form's parent node id (so I have a base location to save to which I will change later.

I get the form/document name by calling

CMS.SettingsProvider.DataClassInfoProvider.GetClasses("*", "className LIKE '%MyDocument.%'", "", Integer.MaxValue).Tables(0).Rows

That returns a dataset which I negotiate for the document name, class id (if I ever need it) and so forth.

I want to change the form that is loaded on postback. That is to say that I have several document types in the CMS Site Manager and I want to swap between them. I want to display one on page load (this works fine). However, when I fire the mechanism to change the form which is displayed (dropdown list OnSelectedIndexChanged), it fails to load the new form.

Private Sub PopulateCMSForm(ByRef targetForm As CMS.FormControls.CMSForm, sourceDDL As ListItem)       
    targetForm.FormName = sourceDDL.Value
    'targetForm.LoadForm() 'same results with or without this
End Sub

I have verified that the form I expect shows up correctly by hard coding the form name (Document type code name) and the form will display just fine the first time the page loads.

How do I manage to change the empty/blank document type that the CMS Form object is loading on post-back?

1 Answer 1

0

try something like this:

Private Sub PopulateCMSForm(ByRef targetForm As CMS.FormControls.CMSForm, sourceDDL As ListItem)       
    targetForm.FormName = sourceDDL.Value
    targetForm.LoadForm(True) 
End Sub

True value as an argument of the method LoadForm should force reload of the form.

3
  • Which does not work since Loading the form causes an error saying that a class was not specified for the node. This behavior implies that LoadForm(true) is to load existing data and not a form template ready for new data. Jun 13, 2016 at 13:06
  • Could you give us an example, what value is set to the FormName property? Is it in valid form/class name format?
    – Plaz
    Jun 13, 2016 at 15:06
  • In this particular instance, the form display name is being set to MyDocument.State#GA-Document. The code name is set to MyDocument_State.GA_Document. Of course, you set the form name to the display name. The document does exist in the the document types of Site Manager and loads using form name (MyDocument.State#GA-Document) correctly the first time the page is loaded. Jun 13, 2016 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.