Loading...

MessageNotify


MessageNotify Example

Please enter a value and click the submit button.





@inherits ControlComponent
<MessageNotifyChild1 />
<br />
<br />
<MessageNotifyChild2 />
MessageNotifyChild1.razor
@inherits ControlComponent
<p>Please enter a value and click the submit button.</p>
<asp.TextBox @ref="this.textBox"></asp.TextBox>
<br />
<br />
<asp.Button OnClick="this.SubmitBtn_Click">Submit</asp.Button>
@code {
                                            private TextBox textBox;

                                            protected void SubmitBtn_Click(object sender, EventArgs e)
    {
                                            this.SendMessage(nameof(MessageNotifyChild2.SetText), textBox.Text);
    }
}
MessageNotifyChild2.razor
@inherits ControlComponent
<asp.Label @ref="this.label"></asp.Label>
@code {
                                            private Label label;

    [MessageNotifyMethod]
                                            public void SetText(string value)
    {
        label.Text = value;
                                            this.StateHasChanged();
    }
}
Copyright © 2023 Jurio li All rights reserved.
An unhandled error has occurred. Reload 🗙