Another problem, I want to disable the modification page with the “Security () → setCanEdit (FALSE)” function, based on a single field called “status” which can take the value of “Closed” or “In progress” and User Level.
In Page_Load I inserted the function like this:
// Page Load event
function Page_Load() {
//echo “Page Load”;
$stato= CurrentPage()->stato->getSessionValue();
$levelid = CurrentUserLevel();
if($levelid <> -1 && $sql == “chiusa”)
{
Security()->setCanEdit(FALSE);
}
}
and also in other ways, but the variable is always NULL.
Maybe I’m wrong to act in page_load?
After 2 years that I still use it, I am wrong with elementary things.
Use “Row_Selected” server event instead.
to disable the field? I want to disable access on the edit page.
No need to disable the Edit page.
By using “Row_Selected” server event, you should be able to prevent your end-users to access the Edit page at all. Just redirect them to your desired page if they do not allowed to access the page.
Thanks, I had already done this via Page_redirecting with a query.
This will save the query on the server side.
I thought it could be done with the Security () function
If you use “Page_Redirecting”, then you need to write the code in each of your desired page(s).
If you use “Row_Selected”, then you may simply write the code in that event (one place) only; just write the condition based on your needs in that event. For example, besides restricting access for Edit Page, you may also want to restrict the access for the View and/or Search page only for the certain user levels, and so forth.
Have you tried by using IsApi() global function?