ClientScript.RegisterClientScriptBlock?

In my web application, when I upload a video and click the "Save" button, if the video is loading, I write code to display the video message. My code is as follows:

ClientScript.RegisterClientScriptBlock(GetType(), "sas", "<script> alert('Inserted successfully');</script>", false); 

When a warning window appears, a white background appears. I clicked the ok button in this notification window, but the page will not return to the previous page, it shows the same empty space.

Can you solve the problem? If you do not understand, I will clearly explain.

In local mode, it works fine, but when I update on the Internet, it does not work.

+6
source share
3 answers

Hai Sridhar, I found the answer to your question

 ClientScript.RegisterClientScriptBlock(GetType(), "sas", "<script> alert('Inserted successfully');</script>", true); 

change false to true

or try this

 ScriptManager.RegisterClientScriptBlock(ursavebuttonID, typeof(LinkButton or button), "sas", "<script> alert('Inserted successfully');</script>", true); 
+15
source share

The System.Web.UI.Page.RegisterClientScriptBlock method has been deprecated for some time (along with other Page.Register * methods), starting with .NET 2.0, as shown in MSDN.

Use the .NET methods of Page.ClientScript.Register * instead . - (The ClientScript property expresses an instance of the ClientScriptManager class)

Guess the problem

If you say that your JavaScript warning window appears before the contents of the page are visually rendered, and therefore the page remains white (or still untransmitted) when the user window is dismissed by the user, then try using Page.ClientScript.RegisterStartupScript (.. ) method , because it runs the given code on the client side when the page finishes loading, and its arguments are similar to reusing it already.

Also check for common JavaScript errors on the page - this is often seen on the error icon in the browser status bar. Sometimes a JavaScript error delays or breaks unrelated elements on a page.

+1
source share

See if the following helps you:

I used the following earlier:

 ClientScript.RegisterClientScriptBlock(Page.GetType(), "AlertMsg", "<script language='javascript'>alert('The Web Policy need to be accepted to submit the new assessor information.');</script>"); 

After implementing AJAX on this page, it stops working. After reading your blog, I changed the above:

 ScriptManager.RegisterClientScriptBlock(imgBtnSubmit, this.GetType(), "AlertMsg", "<script language='javascript'>alert('The Web Policy need to be accepted to submit the new assessor information.');</script>", false); 

It works great.

(its .NET 2.0 Framework I use)

+1
source share

All Articles