Categories
Dynamics NAV Microsoft Tips & Tricks

Tips & Tricks – Trim method in Microsoft Dynamics NAV (Microsoft Business Solutions-Navision)

My Tip & Trick help you to implement Trim function in C/AL for Microsoft Dynamics Nav.

Trim

Removes all white-space characters from the start and end of a string.

You can use the C/AL function DELCHR with the following syntax:

NewString := DELCHR(String [, Where] [, Which])

So, you can use the following code:

String := DELCHR(String,'<>',' ');

TrimStart or LTrim

Removes all white-space characters from the start of a string.

String := DELCHR(String,'<',' ');

TrimEnd or RTrim

Removes all white-space characters from the end of a string.

String := DELCHR(String,'>',' ');

NOTE:
Since “spaces” are used as the default for Which, we can skip the second parameter and write code like this:

String := DELCHR(String,'<>');

Do you think that my Tip & Trick is useful? Leave a reply.

Categories
7.0 7.5 7.8 8.0 C#.NET Microsoft SDK 7.1 SDK 7.8 Visual Studio Windows Phone

The name ‘DisplayModes’ does not exist in the current context

The name ‘DisplayModes’ does not exist in the current context

The error above is caused from the following code:

[sourcecode lang=”csharp”]
@{
Layout = "~/Views/Shared/_Layout.cshtml";
DisplayModes.RequireConsistentDisplayMode = true;
}
[/sourcecode]

Solution:

Replace
[sourcecode lang=”csharp”]DisplayModes.RequireConsistentDisplayMode = true;[/sourcecode]
with
[sourcecode lang=”csharp”]DisplayModeProvider.Instance.RequireConsistentDisplayMode = true;[/sourcecode]

Did my solution solve your problem? Leave a reply.