Monday, August 2, 2010
Disabling Action on Specific Pages

Q.  How can I disable the New and Delete button on any particular page.

A.

Consider using WhenHRef property of data controller actions. Open the data controller definition in Designer, select Actions tab and activate the action. The action property WhenHRef must represent a valid regular expression.

For example, If you want to use New and Delete actions on pages ~/Pages/Page1.aspx and ~/Pages/Page2.aspx only then the following syntax will work.

Page1|Page2

The assumption is made that the same data controller is present on both pages. You can use any valid regular expression to create a URL test.  The expression will be tested against the URL in the web browser address box. A more precise and complex expression may look as the one below:

/Pages/Page(1|2)\.aspx

If there are other pages that use the same data controller and you want to prevent New and Delete actions from displaying on Page1 and Page2 but have them available on all other pages then we recommend to use an extension to regular expression syntax. Simply put "false:" in front of your expression:

false:Page1|Page2

The prefix in the example above is not a part of regular expression definition and is used to make it easier writing negative regular expression then would have been required otherwise.