@using Syncfusion.EJ2.Blazor
@using Syncfusion.EJ2.Blazor.Inputs
<h4>Numeric TextBox</h4>
<EjsNumericTextBox TValue="int?">
<NumericTextBoxEvents TValue="int?" ValueChange="OnChange"></NumericTextBoxEvents>
</EjsNumericTextBox>
<div>
<h6>ChangeValue: @ChangeValue</h6>
</div>
@code{
public int? ChangeValue { get; set; }
public void OnChange(ChangeEventArgs args)
{
this.ChangeValue = (int)args.Value;
}
} |
<EjsNumericTextBox TValue="int?" @bind-Value="@ChangeValue"></EjsNumericTextBox>
<div>
<h6>ChangeValue: @ChangeValue</h6>
</div>
@code{
public int? ChangeValue { get; set; }
} |
<SfTextBox ID="login" ValueChange="ChangeMethod" />
@code{
public void ChangeMethod(ChangedEventArgs args)
{
Console.WriteLine(args.Value);
}
}
|
|
@page "/"
@using Syncfusion.Blazor.Inputs
@using Syncfusion.Blazor.Buttons
@using System.ComponentModel.DataAnnotations;
<div class="row">
<div style="width:100%;margin:20px;">
<EditForm EditContext="@editContext">
<DataAnnotationsValidator />
<div class="form-group">
<SfTextBox Placeholder="Test Property" FloatLabelType='@FloatLabelType.Always' @bind-Value="model.TestProperty" CssClass="@cssClass" Blur="TestPropertyBlurEvent"></SfTextBox>
<ValidationMessage For="() => model.TestProperty" />
</div>
<SfButton IsPrimary="true" HtmlAttributes="@(new Dictionary<string, object> { { "type", "submit" } })">Save</SfButton>
</EditForm>
</div>
</div>
@code{
private void click()
{
cssClass = "cssclasschag";
}
private Test model;
private EditContext editContext;
private string cssClass { get; set; }
protected override void OnInitialized()
{
model = new Test();
editContext = new EditContext(model);
}
public class Test
{
[Required]
public string TestProperty { get; set; }
}
public void TestPropertyBlurEvent(FocusOutEventArgs args)
{
if (!editContext.Validate())
{
cssClass = "e-error";
}
else
{
cssClass = "e-success";
}
StateHasChanged();
}
} |