Professional Documents
Culture Documents
@* commentaires * @
2)
@{
String teststring= ¨tst¨ ;
<p>@teststring</p>
3)
@{
int testing = 0;
@if (testint != 0)
4)
<p>@i</p>
}
5)
<p>test</p>
@code {
int a;
double b = 2.5;
void testmethod() {
}
Blazor Binds
@code {
<input @bind="@teststring">
<textarea @bind="@teststring"></textarea>
2)
Avec oninput les caractères apparaissent au fur et à mesure qu’ils s’écrivent tandis qu’avec onchange
apparait lorsqu’il perd le focus.
<p><input type="text" @bind:event="oninput" @bind="displaytext" /></p>
<p>@displaytext</p>
@code {
3)
The code sections are meant to contain your code for the client side
a)
<p>@testvar</p>
@code {
b)
<p>@testvar</p>
<p><button @onclick="@testmethod">change</button></p>
@code {
void testmethod() {
testvar = "test";
}
The method simply changes the value for the variable, and in turn what is displayed in the paragraph tag
is also changed
c)
<p>@testvar</p>
<p><input @bind="@testvar"></p>
<p><button @onclick="@(() => testmethod())">change</button></p>
@code {
string testvar = "nothing to display";
void testmethod()
{
testvar = "test value";
}
}
an input tag is bound to the testvar variable , so whenever the input tag value changes, the variable will
also change, and therefore the display in the paragraph tag also changes.
d)
<p>@testvar</p>
<p><input @bind="@testvar"></p>
@code {
{
testvar = testparam;
}
e)
<p>@testvar</p>
@code {
{
}
}
Listing 2-13Asynchronous Task
e)
@code {
f)
<p>@testvar</p>
@code {
@page "/"
<h1>Index page</h1>
@code {
{
return base.OnInitializedAsync();
}
}
After the page gets rendered, the OnAfterRenderAsync event occurs (Listing 2-17). This can be used for
procedures that require UI elements to be fully loaded.
protected override Task OnAfterRenderAsync(bool firstRender)
{
return base.OnAfterRenderAsync(firstRender);
}
This event will also recur if there are any updates to the page or
if StateHasChanged() has been invoked (covered later in the book). Therefore, if you
want to use it only on the initial render, you can check if the Boolean value is true.
a)
@page "/page1"
<p>page 1</p>
b)
@page "/"
<p><a href="/page1">navigate to page 1</a></p>
Listing 3-2Contents of Index.razor
c)
@page "/page1/{ExampleParam}"
<p>page 1</p>
@code {
[Parameter]