0
I’m needing to use a script from an Alert() in my project . NET core Razor, and when I add the line:
Page.ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Hello World')", true);
Gives the following error:
'Pagemodel.Page()' is a method, which is not Valid in the Given context
Help me please, I don’t know how to fix it... I tried to remove the Page.
and it goes like this:
The name 'Scriptmanager' does not exist in the Current context
And I can’t use the using System.Web.UI;
Method:
public async Task OnPostAsync(PARAMETROS){
CancellationTokenSource backGroundTask = new CancellationTokenSource();
MobAtivacaoAcesso MobAtivacaoAcesso = new MobAtivacaoAcesso("X", "Z");
await MobAtivacaoAcesso.AtivacaoVerificarAsync(PARAMETROS);
if (!String.IsNullOrEmpty(MobAtivacaoAcesso.MensagemTemporaria)){
Response.Headers.Add("mensagem", MobAtivacaoAcesso.MensagemTemporaria);
}
return;
}
After all, what kind of project are you with? MVC, Webforms, Razor Pages? which one?
– novic
Not to be rude, but it’s in question... . NET core Razor....
– user149429
is Razor Pages and what in question is Web Forms then what you want to do because that code doesn’t work on Razor Pages?
– novic
What do you want to do with a
alert
? your code doesn’t work– novic
i would like to make the Alert of a message that is being returned from a method
– user149429
post the method?
– novic
Sure, @Virgilionovic, I’ll leave the code in the question
– user149429
In case, if I could use the Script, it would be in place of this
Response.Headers.Add("mensagem", MobAtivacaoAcesso.MensagemTemporaria);
– user149429
Let’s go continue this discussion in chat.
– novic