Comments (1)
There is no way to migrate it exactly the same as the original lifecycle.
It becomes an independent page lifecycle for each ControlComponent.
OnUpdate is the event that triggers the execution of StateHasChanged.
When clicking, only the page lifecycle of Button is executed and then other components update render are notified.
@page "/mypage"
@using System.Web.UI
@using System.Web.UI.WebControls
@inherits ControlComponent
<asp.TextBox ID="Val" TextMode="TextBoxMode.Date" @ref="this.myval">
</asp.TextBox>
<asp.Button _ref="() => this.button" Text="Add" OnClick="this.AddButton_Click" />
<h1>@res?.ToString()</h1>
<h1>
<asp.Label _ref="() => this.msg" />
</h1>
@code {
Button button = new Button();
Label msg = new MsgLabel();
protected override void OnInitialized()
{
this.Control.Init += Control_OnInit;
this.Control.Load += Control_OnLoad;
this.Control.PreRender += Control_OnPreRender;
button.Init += Button_OnInit;
button.Load += Button_OnLoad;
button.PreRender += Button_OnPreRender;
base.OnInitialized();
}
public void Control_OnInit(object sender, EventArgs e)
{
msg.Text += "Init (Control), ";
}
public void Button_OnInit(object sender, EventArgs e)
{
msg.Text += "Init (Button), ";
}
protected void Control_OnLoad(object sender, EventArgs e)
{
if (!this.Page.IsPostBack)
{
msg.Text += "First Load (Control), ";
}
else
{
msg.Text += "Postback Load (Control), ";
}
}
protected void Button_OnLoad(object sender, EventArgs e)
{
if (!this.Page.IsPostBack)
{
msg.Text += "First Load (Button), ";
}
else
{
msg.Text += "Postback Load (Button), ";
}
}
public void Control_OnPreRender(object sender, EventArgs e)
{
msg.Text += "Prerender (Control), ";
}
public void Button_OnPreRender(object sender, EventArgs e)
{
msg.Text += "Prerender (Button), ";
}
TextBox myval = null;
DateTime? res = null;
protected void AddButton_Click(object sender, EventArgs e)
{
res = Convert.ToDateTime(myval.Text);
msg.Text += "Click Handler, ";
// this.RequestRefresh();
StateHasChanged();
}
protected override void OnUpdate(object sender, StateUpdateEventArgs e)
{
// how to use this?
base.OnUpdate(sender, e);
// dialogService.Alert("Update.");
}
public class MsgLabel : Label
{
protected override void Render(HtmlTextWriter writer)
{
this.Text += "Render (Label), ";
base.Render(writer);
}
}
}
Init (Control), First Load (Control), Prerender (Control), Init (Button), First Load (Button), Prerender (Button), Render (Label),
Postback Load (Button), Click Handler, Render (Label), Prerender (Button), Render (Label),
from blazor.webform.components.
Related Issues (17)
- Wizzard crash HOT 1
- Anyone migrated from webform to blazor?
- Textbox fails to update when post triggered from same button HOT 2
- This code needs a license
- Will this work with .net 8 Blazor SSR HOT 1
- About the demo HOT 4
- components don't work on .net 8 HOT 1
- Blazor.WebForm.UI HOT 1
- asp.GridView / asp.BoundField HOT 2
- Setting component's Properties by their References (@ref) HOT 1
- Getting a reference to a control inside gridview row in OnRowDataBound HOT 5
- The remaining controls HOT 1
- Custom Validator not showing HOT 2
- For ListView: The datasource keys["Id"] for OnExecuteUpdated method is lower than the actual Id HOT 6
- CheckBox's Parent is null (in Gridview) HOT 1
- GridView "Select" command and SelectedIndexChanged stops the circuit HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blazor.webform.components.