Technical support This forum is closed.
Version 1.x > Technical support > Template problem when creating a new document (and solution) View modes: 
User avatar
Member
Member
james - 10/14/2005 4:42:24 AM
   
Template problem when creating a new document (and solution)
Hello,
I've just downloaded and installed the trial version (1.7.2091), but was unable to create any new pages.
I applied the changes to allow multilingual support, but when attempting to create a French version, I was unable to save due to two template error.

Problem #1
Selected a page under "en-us", then switched the language drop down to French.
Left the "Prefill values with data from the default culture version" checkbox set and pressed the create button.
The brought me to the Create a New Document page, which had many think pre-filled including the "Page Template".
Pressed OK on this form, and received the error "Please choose some page template.", and the page template value had now disappeared.

Solution
In CMS_MenuItemType.ascx, I removed the read only attribute from txtPageTemplate. Although this now made the page template box editable (the hidden field is used anyway), pages would then save without any errors.

Problem #2
Pressed the Select button to change the template.
On the popup, picked a template, pressed OK, and a javascript error appeared. Didn't capture the exact message, but it was to do with getElementById

Solution
The txtPageTemplate textbox and hidPageTemplateAspx hidden field are rendered with IDs of CMSForm1_ctl00_MenuItemType_txtPageTemplate and CMSForm1_ctl00_MenuItemType_hidPageTemplateAspx, however the SelectTemplateListing.aspx page is trying to update controls with IDs of CMSForm1__ctl0_MenuItemType_txtPageTemplate and CMSForm1__ctl0_MenuItemType_hidPageTemplateAspx.

Changing Line 112 in SelectTemplateListing.aspx.cs as follows corrected this problem
RunScript( " opener.document.getElementById('CMSForm1__ctl0_MenuItemType_hidPageTemplateAspx').value = '" + Strings.Replace( this.lstTemplates.SelectedValue, "'", @"\'", 1, -1, (Microsoft.VisualBasic.CompareMethod)(0) ) + "'; " + "opener.document.getElementById('CMSForm1__ctl0_MenuItemType_txtPageTemplate').value = '" + Strings.Replace( this.lstTemplates.SelectedItem.Text, "'", @"\'", 1, -1, (Microsoft.VisualBasic.CompareMethod)(0) ) + "';window.close();" );
to
RunScript( " opener.document.getElementById('CMSForm1_ctl00_MenuItemType_hidPageTemplateAspx').value = '" + Strings.Replace( this.lstTemplates.SelectedValue, "'", @"\'", 1, -1, (Microsoft.VisualBasic.CompareMethod)(0) ) + "'; " + "opener.document.getElementById('CMSForm1_ctl00_MenuItemType_txtPageTemplate').value = '" + Strings.Replace( this.lstTemplates.SelectedItem.Text, "'", @"\'", 1, -1, (Microsoft.VisualBasic.CompareMethod)(0) ) + "';window.close();" );

I didn't notice any other posts about this problem, so maybe it's only me who is experiencing this behaviour, but thought I'd post the solutions which I discovered incase there were others.

James.

User avatar
Guest
admin - 10/14/2005 9:17:26 AM
   
Re: Template problem when creating a new document (and solution)
Hi James,

Thank you very much for this post. This usually happens when you run Kentico CMS on ASP.NET 2.0 web site. For some reason, ASP.NET 2.0 generates different control ID's which causes the errors then.

Could you please check if you're running Kentico CMS on ASP.NET 1.1?

We plan to release a new version with full ASP.NET 2.0/VS.NET 2005 support at the end of October.

Best Regards,