Add Java Script Code into page type edit form

Aasim Khan asked on September 29, 2015 14:52

Hello ,

How can i add java script code into page type edit form.

Regards, Aasim Afridi

Recent Answers


Brenden Kehren answered on September 29, 2015 16:07

On the page type definition there are boxes toward the bottom of the General tab. There you can define URLs of the custom pages you create with your JS in them.

What are you looking to do? There are some things you can do within the field definition which may accomplish your needs.

0 votesVote for this answer Mark as a Correct answer

Aasim Khan answered on September 29, 2015 21:19

Hello Brenden,

Thanks for reply.

Can you tell me where i need to define URL. Can you give me example link? I need to perform some action in java script so i need to add javascript file into page edit form.

Regards, Aasim Afridi

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on September 29, 2015 21:27

Sorry, I wasn't very clear in my first post. You will have to manually create an aspx page or a ascx webpart and place it on a page. This control or page would then be stored in the physical file system. Then in your page type on the General tab, towards the bottom there are some properties for the page type (Editing pages settings), you need to set the URL there. So with this option, you are physically creating code.

Again, I'll ask, what is the javascript for or what are you trying to accomplish? There may be an alternative without writing any code.

0 votesVote for this answer Mark as a Correct answer

Joshua Adams answered on September 29, 2015 21:29

You could also create a form control that would be placed into your document type or form. This would allow you to use it in multiple places/forms. But as Brenden asked, what exactly do you need javascript for? You may be able to use a macro or something along those lines instead.

0 votesVote for this answer Mark as a Correct answer

Aasim Khan answered on September 30, 2015 14:56

Hi All,

I have created a form control that comprises of a CustomTableForm Control which has a property to select a customtable. I have created a page type "Recipe" and a CustomTable "Ïngredients". The page type has some fields and the ÏNgredients" customtable has some different set of fields. Now my form control displays the set of fields in the customtable on the PageType Form as shown in "3 Page Creation.jpg". Now the user enters the customtable fields values and clicks on "ADD" which inserts a record in the "Ingredients" customtable and saves its ItemGUID to a hiddenfield to override the "Value" property of the FormControl. It also displays all the records of the customtable in a Grid whose ItemGUID values are present in the "Value" property of the formcontrol. Now what I want is based on change of a field in the page type, the customtable field should be enabled or disabled. Now since the Customtable and Page type are different units but are only displayed as a single entity, I am unable to access the PageType's field in the Customtable "Enabled" macro field. Below are the links to provide you a better picture of how my Page Type, Customtable and Page Type Form is displayed.

Since I am unable to access the field value, I thought why not handle it by Javascript if its isn't possible through Kentico's usual norms.

Image Text link text

Image Text link text

Image Text link text

Thanks, Aasim

0 votesVote for this answer Mark as a Correct answer

Aasim Khan answered on September 30, 2015 15:00

Hello Brendon,

In the bottom of the general tab i am not able to see 'Editing form' text field where i can add page url. So do we need set any configuration to see that because except this we can see 'Editing Page, Preview Page and List Page'.

Regards, Aasim Afridi

0 votesVote for this answer Mark as a Correct answer

Joshua Adams answered on October 2, 2015 17:01

What you could do here is to set the field that will control the visibility of your custom form control to have depending fields, which will inturn cause a postback. Then in your custom form control, your page load method can access the form and get the value of the field that you want to use to check the value. Then set your enabled property or visible property. You should be able to access the form property from this.Form or something similar from your form control, if it is registered properly. Then you can get the field from the form and check the value.

1 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on October 3, 2015 05:37

Based on your answer, I'd go the route Josh mentioned and add your look up code in the load event of your form control.

0 votesVote for this answer Mark as a Correct answer

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