Custom control

Eoin Maguire asked on March 24, 2014 10:11

I've got a couple of custom tables that I want to use with a new control I'm building. One of the tables is 'type' and the other is 'area', depending on the page the user is on I need this control to show different info in drop downs.

For example I have a page in the site called 'Shops' and when this control is on that page I want the 'type' dropdown preselected to 'shops'. If the user then changes the page to a different page called 'bus routes' I want the dropdown for 'type' to have 'bus routes' preselected.

Equally if they go to a page called 'manhattan' the 'area' drop down is preselected to manhattan and they can choose the 'type' from the other drop down.

I can build the control easily enough but I'm not sure how to connect it with the various pages. By this I mean I don't know how to make a page called 'manhattan' mean 'areaId = 56' to the control. I can do a page name check but that's not robust and breaks if the name changes.

What's the best way of doing this so that the control is as re-useable as possible?

Correct Answer

Brenden Kehren answered on March 24, 2014 12:45

You can add a new field to the cms.menuitem document type. Set the datatype to text and select DropDown as the control type. Then set the query (select * from customtable_name) to draw a list of values and names from the custom table. This will allow the user to set the value on the page itself and you can then display it as needed or get the value in your webpart code.

1 votesVote for this answer Unmark Correct answer

Recent Answers

Richard Sustek answered on April 1, 2014 03:32


Thank you for your message.

You can also have a new table like NodeAreaAssingment where you would store the NodeID and AreaID. By looking at this table you can get the Area name and preselect it in your control. Its also safe if you change both NodeName or other properties and AreaName.

Kind regards, Richard Sustek

0 votesVote for this answer Mark as a Correct answer

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