Select theme:

Material 3

Methods and Statementslink

Methods are the bread and butter of every Blazor application. You use them to query a database, respond to user actions, handle Blazor lifecycle events and more.

You can manage methods and their statements of your Blazor components or C# classes via Radzen Blazor Studio's Methods design mode.

To access Methods design mode open a .razor or .cs file and click the corresponding button in the design canvas toolbar.

Radzen Blazor Studio will display a dropdown with all methods that are accessible are accessible from the current class / component.

Radzen Blazor Studio lists methods that may be defined in other files (when you use partial classes for example).

Methods consist of statements - basically one or more lines of code that perform certain task. For example assignments, loops, if checks, try/catch blocks, method invocations et. al.

Radzen Blazor Studio allows you to visually edit a method by adding or removing statements to it.

Invoke a method and assign its result to a fieldlink

Invoking a service method and assigning its result to a field is a common task in Blazor development. Here is how to do it with Radzen Blazor Studio.

  1. Open a .razor file and enter Methods design mode.
  2. Pick OnInitializedAsync from the Override dropdown. It lists all Blazor lifecycle methods which are not yet overridden by your component.
  3. Click the + button below the start box and pick Invoke from the popup.
  4. Select the Method you wish to invoke. Start typing its name and Radzen Blazor Studio will suggest you the available options - all methods of the injected services as well as the own methods of the current file.
  5. If the chosen method returns a value you can set Result as well. You can either pick an existing field or property to assign the result to or create a new one.
Invoke a method

Supported statementslink

Radzen Blazor Studio provides built-in support for the following statements.

Assignmentlink

Assign values to existing fields, properties or variables.

Declarationlink

Declare method variables to store method or computation results.

Iflink

Create C# if statements.

Switchlink

Create C# switch statements.

Forlink

Create C# for loops.

ForEachlink

Create C# foreach loops.

Do/Whilelink

Create C# do/while loops.

Whilelink

Create C# while loops.

Invokelink

Invoke own methods or methods of properties or fields.

Navigatelink

Use the NavigationManager to navigate to a page. A page is a Blazor component with a @page directive.

Navigate Backlink

Return to the previous page.

Try/Catchlink

Create a try/catch block.

Usinglink

Create a C# using statement.

Notifylink

Display a notification message. Uses the Radzen.Blazor library's NotificationService.

Open Dialoglink

Display a dialog. Uses the Radzen.Blazor library's DialogService.

Close Dialoglink

Closes the current dialog. Uses the Radzen.Blazor library's DialogService.

Open Context Menulink

Opens a context menu. Uses the Radzen.Blazor library's ContextMenuService.

Show Tooltiplink

Opens a tooltip. Uses the Radzen.Blazor library's TooltipService.

Executelink

Any other C# statement.

Important: statements that require the Radzen.Blazor component library are available only in applications that have Radzen.Blazor correctly installed and the required services registered.

© 2016-2025 Radzen Ltd. All Rights Reserved.
Designed and developed with ❤️ in Radzen Blazor Studio.

Select theme:

Material 3