Javascript warning field called with codebehind not working

I need alerts to inform the user about successful login or data conflicts. I have tried the following and I am not getting any errors and no warnings.

In Save_Click:

ClientScript.RegisterStartupScript (GetType(), "Javascript", "javascript: UpdateComplete(); ", true); 

and...

  ClientScript.RegisterClientScriptBlock(GetType(), "Javascript", "<script>alert('Record Added Successfully')</script>"); 

and...

  Save.Attributes.Add("onclick","return ReqField1Validator()"); 

I used GetType and TypeOf both.

  ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "alert", "alert('See me?');", true); return; 

I also tried a very popular offer.

  Response.Write("<script>alert('Hello');</script>"); 

and nothing works. I tried a lot of options on them, moved them to the Updated method and the Click method, and so on, and nothing happens.

Can someone tell me what I'm doing wrong or what I don’t notice? Thanks for your time and patience.

+4
source share
1 answer

buddy here

  string script = "alert('its working now!')"; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "its working", script, true); 

just tested it and guaranteed its work

regarsd

+5
source

Source: https://habr.com/ru/post/1480145/


All Articles