Skip to content

Commit 080929f

Browse files
VelinovAngelnikolay-nenkov
authored andcommitted
Fix: Some wrong codeblocks
1 parent e166aaa commit 080929f

9 files changed

+113
-109
lines changed

knowledge-base/common-lazy-load-assemblies-wasm.md

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -39,38 +39,44 @@ All general guidance from the [Microsoft documentation](https://learn.microsoft.
3939

4040
* List the following assemblies in the "client" `.csproj` file to be lazy loaded.
4141

42-
````XML
43-
<ItemGroup>
44-
<!-- Components and data binding -->
45-
<BlazorWebAssemblyLazyLoad Include="Telerik.Blazor.dll" />
46-
<BlazorWebAssemblyLazyLoad Include="Telerik.DataSource.dll" />
47-
<BlazorWebAssemblyLazyLoad Include="System.Data.Common.dll" />
48-
<BlazorWebAssemblyLazyLoad Include="System.Linq.Queryable.dll" />
49-
<!-- Icons -->
50-
<BlazorWebAssemblyLazyLoad Include="Telerik.SvgIcons.dll" />
51-
<BlazorWebAssemblyLazyLoad Include="Telerik.FontIcons.dll" />
52-
<!-- PivotGrid -->
53-
<BlazorWebAssemblyLazyLoad Include="Telerik.Pivot.Core.dll" />
54-
<BlazorWebAssemblyLazyLoad Include="Telerik.Pivot.DataProviders.Xmla.dll" />
55-
<!-- Scheduler -->
56-
<BlazorWebAssemblyLazyLoad Include="Telerik.Recurrence.dll" />
57-
<!-- Excel export -->
58-
<BlazorWebAssemblyLazyLoad Include="Telerik.Documents.SpreadsheetStreaming.dll" />
59-
<BlazorWebAssemblyLazyLoad Include="Telerik.Zip.dll" />
60-
</ItemGroup>
61-
````
42+
````XML.skip-repl
43+
<ItemGroup>
44+
<!-- Components and data binding -->
45+
<BlazorWebAssemblyLazyLoad Include="Telerik.Blazor.dll" />
46+
<BlazorWebAssemblyLazyLoad Include="Telerik.DataSource.dll" />
47+
<BlazorWebAssemblyLazyLoad Include="System.Data.Common.dll" />
48+
<BlazorWebAssemblyLazyLoad Include="System.Linq.Queryable.dll" />
49+
<!-- Icons -->
50+
<BlazorWebAssemblyLazyLoad Include="Telerik.SvgIcons.dll" />
51+
<BlazorWebAssemblyLazyLoad Include="Telerik.FontIcons.dll" />
52+
<!-- PivotGrid -->
53+
<BlazorWebAssemblyLazyLoad Include="Telerik.Pivot.Core.dll" />
54+
<BlazorWebAssemblyLazyLoad Include="Telerik.Pivot.DataProviders.Xmla.dll" />
55+
<!-- Scheduler -->
56+
<BlazorWebAssemblyLazyLoad Include="Telerik.Recurrence.dll" />
57+
<!-- Excel export -->
58+
<BlazorWebAssemblyLazyLoad Include="Telerik.Documents.SpreadsheetStreaming.dll" />
59+
<BlazorWebAssemblyLazyLoad Include="Telerik.Zip.dll" />
60+
</ItemGroup>
61+
````
6262

6363
* The assembly requirements depend on component usage, and not on feature usage. For example, both icon assemblies are always required, as our components render icons internally and must be aware of both types of icons. The assemblies, which are related to Excel export, are always required when using a Grid. `Telerik.Recurrence.dll` is required only when using the Scheduler.
6464
* Move the [`<TelerikRootComponent>`]({%slug rootcomponent-overview%}) to a layout that is used only on pages that have the Telerik assemblies loaded.
6565
* Lazy loading of assemblies does not support dynamic service injection. As a result, remove the Telerik service registration (`builder.Services.AddTelerikBlazor();`) from `Program.cs`. If you are using [localization for the Telerik Blazor components]({%slug globalization-localization%}), define the the localization service for the Telerik components with the `Localizer` parameter of the `<TelerikRootComponent>`. The key thing is to instantiate the localization service inline. It cannot be injected as a variable from the `@code { }` block, because that will throw runtime errors.
6666

67-
````RAZOR
68-
@using LazyLoadTelerikComponents.Shared.Services
6967

70-
<TelerikRootComponent Localizer="@( new SampleResxLocalizer() )">
71-
...
72-
</TelerikRootComponent>
73-
````
68+
````RAZOR.skip-repl
69+
70+
@using LazyLoadTelerikComponents.Shared.Services
71+
72+
73+
<TelerikRootComponent Localizer="@( new SampleResxLocalizer() )">
74+
75+
...
76+
77+
</TelerikRootComponent>
78+
79+
````
7480

7581
Overall, the lazy loading of assemblies at the correct time is a responsibility of the application. If an assembly is not loaded when required, the app will throw `System.IO.FileNotFoundException: Could not load file or assembly ...`. The loading code is in the `OnNavigateAsync` event handler of the `<Router>`. You can also define an optional loading screen inside the `<Router>` with a `<Navigating>` tag.
7682

@@ -81,11 +87,10 @@ The following tips apply only to .NET 8 and 9 WebAssembly apps:
8187
* Use `.wasm` instead of `.dll` in the `.csproj` file and the `OnNavigateAsync` event handler.
8288
* [Register the lazy loader service manually](https://github.com/dotnet/aspnetcore/issues/51966) in the "server" `Program.cs`. Otherwise, you may get a `InvalidOperationException: Cannot provide a value for property 'AssemblyLoader' on type '...Routes'. There is no registered service of type 'Microsoft.AspNetCore.Components.WebAssembly.Services.LazyAssemblyLoader'.`
8389

84-
````C#
85-
using Microsoft.AspNetCore.Components.WebAssembly.Services;
86-
87-
builder.Services.AddScoped(typeof(LazyAssemblyLoader));
88-
````
90+
````C#.skip-repl
91+
using Microsoft.AspNetCore.Components.WebAssembly.Services;
92+
builder.Services.AddScoped(typeof(LazyAssemblyLoader));
93+
````
8994

9095
## Example
9196

knowledge-base/common-newtonsoft-breaks-datasourcerequest-serialization.md

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -74,29 +74,26 @@ The different serializers are not 100% compatible with each other, and each has
7474
Use explicit System.Text.Json serialization when needed:
7575

7676
* to serialize the DataSourceRequest - make it explicit in the WASM app service:
77-
78-
**C#**
79-
80-
public async Task<DataEnvelope<WeatherForecast>> GetForecastListAsync(DataSourceRequest gridRequest)
81-
{
82-
HttpResponseMessage response = await Http.PostAsJsonAsync(
83-
"WeatherForecast",
84-
JsonSerializer.Serialize<DataSourceRequest>(gridRequest)
85-
);
86-
. . .
87-
}
88-
77+
78+
````C#.skip-repl
79+
public async Task<DataEnvelope<WeatherForecast>> GetForecastListAsync(DataSourceRequest gridRequest)
80+
{
81+
HttpResponseMessage response = await Http.PostAsJsonAsync(
82+
"WeatherForecast",
83+
JsonSerializer.Serialize<DataSourceRequest>(gridRequest)
84+
);
85+
}
86+
````
8987

9088
* when deserializing it - don't let the framework deserialize with the registered serialized (Newtonsoft) but take it as a string in the action and deserialize explicitly there with System.Text.Json:
9189

92-
**C#**
93-
94-
[HttpPost]
95-
public async Task<DataEnvelope<WeatherForecast>> Post([FromBody] string gridRequestAsString)
96-
{
97-
DataSourceRequest gridRequest = JsonSerializer.Deserialize<DataSourceRequest>(gridRequestAsString);
98-
. . .
99-
}
90+
````C#.skip-repl
91+
[HttpPost]
92+
public async Task<DataEnvelope<WeatherForecast>> Post([FromBody] string gridRequestAsString)
93+
{
94+
DataSourceRequest gridRequest = JsonSerializer.Deserialize<DataSourceRequest>(gridRequestAsString);
95+
}
96+
````
10097

10198
## Suggested Workarounds
10299

knowledge-base/common-struct-error.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ res_type: kb
2424

2525
When using a data-bound component, the application gets a null exception, and the component does not work. When running the Telerik Blazor application the application gets an error similar to the following:
2626

27-
````C#
27+
````C#.skip-repl
2828
ArgumentNullException: Value cannot be null. (Parameter 'source')
2929
System.Linq.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
3030
````
@@ -85,14 +85,14 @@ The solution is to always bind the component to a `class` model, not a `struct`.
8585
<div class="skip-repl"></div>
8686

8787
````CS
88-
public class Product
89-
{
90-
public int Id { get; set; }
91-
public string Name { get; set; }
92-
public decimal Price { get; set; }
93-
public DateTime Released { get; set; }
94-
public bool Discontinued { get; set; }
95-
}
88+
public class Product
89+
{
90+
public int Id { get; set; }
91+
public string Name { get; set; }
92+
public decimal Price { get; set; }
93+
public DateTime Released { get; set; }
94+
public bool Discontinued { get; set; }
95+
}
9696
````
9797

9898
## See Also

knowledge-base/dropdowns-readonly-struct-error.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ When using the combo box component when the desired data is list of readonly str
2727
## Error Message
2828
A typical error would be null reference exception like the one below:
2929

30-
````C#
30+
````C#.skip-repl
3131
NullReferenceException: Object reference not set to an instance of an object.
3232
Telerik.Blazor.Components.TelerikComboBox<TItem, TValue>.<OnParametersSetAsync>b__70_0(ListDataItem item)
3333
````
@@ -71,12 +71,13 @@ There are two approaches to avoiding this error:
7171
* When setting the `Data` of the dropdown, make it a collection of anonymous objects, for example:
7272

7373
**Razor**
74-
75-
@* See the Select in the Data parameter *@
76-
77-
<TelerikComboBox Data="@myComboData.Select(x => new {MyTextField = x.MyTextField, MyValueField = x.MyValueField })"
78-
TextField="MyTextField" ValueField="MyValueField"
79-
@bind-Value="selectedValue"
80-
Placeholder="Select an item..." ShowClearButton="true" Filterable="false">
81-
</TelerikComboBox>
74+
````RAZOR.skip-repl
75+
@* See the Select in the Data parameter *@
76+
77+
<TelerikComboBox Data="@myComboData.Select(x => new {MyTextField = x.MyTextField, MyValueField = x.MyValueField })"
78+
TextField="MyTextField" ValueField="MyValueField"
79+
@bind-Value="selectedValue"
80+
Placeholder="Select an item..." ShowClearButton="true" Filterable="false">
81+
</TelerikComboBox>
82+
````
8283

knowledge-base/grid-number-formatting-of-the-csv-export.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ To format numeric and date cells of the exported file before it reaches the clie
5151

5252
1. Pass that `MemoryStream` to the `args.Stream` of the `GridAfterCsvExportEventArgs`, so that the modifications can be saved to the actual exported file.
5353

54-
````RAZOR
54+
````RAZOR.skip-repl
5555
@*Use RadSpreadProcessing to format numeric data in the exported CSV file*@
5656
5757
@using Telerik.Windows.Documents.Spreadsheet.FormatProviders.TextBased.Csv

knowledge-base/requires-valueexpression.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ There are three common ways to resolve such an error:
4545
* Use two-way binding - the `@bind-Value` syntax if you can. If you wrap our components inside a custom one for your application you need to implement both two-way data binding and `ValueExpression`, read this article for more information: [Validate a Telerik component as child control and apply invalid border ]({%slug inputs-kb-validate-child-component%}). If you need to handle the `ValueChanged` even to implement logic, see this article: [How to handle the ValueChanged event and use forms and validation]({%slug value-changed-validation-model%}). It shows how to use the `ValueExpression` parameter and also hints at using the Telerik-specific `OnChange` event that does not prevent two-way binding.
4646
* Provide a `ValueExpression` to the component. This is a lambda function that tells the framework what field in the model to update. It is required by the framework when you cannot use `@bind-Value`, but the component is inside a form. The article in the previous point shows an example.
4747
* You may want to always provide a `ValueExpression` when expecting to reuse input components inside wrapped in a component. This makes them more likely to work when placed inside an `EditForm` from a parent component.
48-
49-
**Razor**
50-
51-
<TelerikTextBox
52-
Value="@myModel.MyField"
53-
ValueExpression="@( () => myModel.MyField )">
54-
</TelerikTextBox>
55-
56-
@* Applies to the other input type components as well *@
57-
48+
49+
````RAZOR.skip-repl
50+
<TelerikTextBox
51+
Value="@myModel.MyField"
52+
ValueExpression="@( () => myModel.MyField )">
53+
</TelerikTextBox>
54+
55+
@* Applies to the other input type components as well *@
56+
````
57+
5858
* Move the `EditForm` inside the component that hosts all the input. This will make it throw the exception immediately, not only when used in a particular case. This will let you evaluate how to solve the situation according to the previous points, and can let you expose only relevant events/logic/parameters to its parents, instead of expecting them to provide a form and validator.
5959
* If you do not define a `Value` at all, consider whether such an input needs to be in the form in the first place (for example, putting an `<InputText />` in an `EditForm` without defining the value and binding settings will throw the same error.

knowledge-base/textbox-select-in-focus.md

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -32,36 +32,37 @@ At the time of writing, Blazor does not have native API for handling focus and s
3232

3333
1. Prepare a small JavaScript function that will call the [select](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/select) method of the input.
3434

35-
**JavaScript**
36-
37-
<script>
38-
function selectText(tbId) {
39-
var tb = document.querySelector("#" + tbId);
40-
if (tb.select) {
41-
tb.select();
42-
}
43-
}
44-
</script>
35+
````JavaScript.skip-repl
36+
<script>
37+
function selectText(tbId) {
38+
var tb = document.querySelector("#" + tbId);
39+
if (tb.select) {
40+
tb.select();
41+
}
42+
}
43+
</script>
44+
````
4545

4646
1. Call that function in the desired event like `@focusin`. See how to get such events [here]({%slug inputs-kb-handle-keyboard-events%}).
4747

48-
**Razor**
49-
50-
@inject IJSRuntime _js
51-
52-
<span @onfocusin="@FocusInHandler">
53-
<TelerikTextBox @bind-Value="@TbValue" Id="@TheTbId"></TelerikTextBox>
54-
</span>
55-
56-
@code{
57-
string TbValue { get; set; } = "lorem ipsum";
58-
string TheTbId { get; set; } = "myTb";
59-
60-
async Task FocusInHandler(FocusEventArgs e)
61-
{
62-
await _js.InvokeVoidAsync("selectText", TheTbId);
63-
}
64-
}
48+
49+
````RAZOR.skip-repl
50+
@inject IJSRuntime _js
51+
52+
<span @onfocusin="@FocusInHandler">
53+
<TelerikTextBox @bind-Value="@TbValue" Id="@TheTbId"></TelerikTextBox>
54+
</span>
55+
56+
@code{
57+
string TbValue { get; set; } = "lorem ipsum";
58+
string TheTbId { get; set; } = "myTb";
59+
60+
async Task FocusInHandler(FocusEventArgs e)
61+
{
62+
await _js.InvokeVoidAsync("selectText", TheTbId);
63+
}
64+
}
65+
````
6566

6667

6768

testing/unit-testing-with-justmock.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ As you are already guessing, JustMock is especially useful when unit testing you
3737

3838
Here is example of how this looks:
3939

40-
````C#
40+
````C#.skip-repl
4141
[Fact]
4242
public void TestFetchData_PredefinedForecast()
4343
{

troubleshooting/nuget-feed.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ To solve the issue:
8787

8888
Avoid using an online encoder utility for a password. Instead, use a Powershell command:
8989

90-
````SH
90+
````SH.skip-repl
9191
Add-Type -AssemblyName System.Web
9292
[System.Web.HttpUtility]::HtmlEncode('my§uper&P@§§word')
9393
````

0 commit comments

Comments
 (0)