TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Tomas Ambrulaitis
NA
6
443
Function runs 'onlick' but not on 'onchange' in blazor app with event
Nov 2 2020 1:33 PM
I have two ways of running function in my Blazor app.
<h1 @onchange=
"e => action(message)"
>@message</h1>
<button @onclick=
"e => action(message)"
>Click</button>
The first code line should work on change meanwhile the second works on click. I cannot find out why the first one is not working. My program logic is as follows:
@code {
GameManager _gameM;
public
string
message {
get
;
set
; } =
"test"
;
protected
override
void
OnInitialized()
{
_gameM =
new
GameManager();
_gameM.MainLoopCompleted += (e, o) => StateHasChanged();
_gameM.MainLoopCompleted += (e, o) => special();
}
public
async Task action(
string
message)
{
var confirmed = await js.InvokeAsync<
bool
>(
"confirm"
, $
"{message}"
);
if
(confirmed)
{
Console.WriteLine(
"working"
);
}
}
public
void
special()
{
message = _gameM.message;
}
}
In this code I have a line:
_gameM.MainLoopCompleted += (e, o) => special();
Which for sure changes @message inside <h1>, however, the function action() is not triggered by this change. Why is it so and how to solve it?
Reply
Answers (
1
)
Question About Web API in .netCore??
ASP.Net with Angular 10