ClientScript.RegisterClientScriptBlock?

后端 未结 3 617
情歌与酒
情歌与酒 2020-12-06 18:30

In my web application when i upload a video and click the save button, if the video is uploaded i write the code to display the message video is uploaded. My code is as foll

相关标签:
3条回答
  • 2020-12-06 19:10

    See if the below helps you:

    I was using 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 in this page, it stopped working. After reading your blog, I changed the above to:

    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);
    

    This is working perfectly fine.

    (It’s .NET 2.0 Framework, I am using)

    0 讨论(0)
  • 2020-12-06 19:15

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

    Instead use the .NET 2.0 Page.ClientScript.Register* methods. - (The ClientScript property expresses an instance of the ClientScriptManager class )

    Guessing the problem

    If you are saying your JavaScript alert box occurs before the page's content is visibly rendered, and therefore the page remains white (or still unrendered) when the alert box is dismissed by the user, then try using the Page.ClientScript.RegisterStartupScript(..) method instead because it runs the given client-side code when the page finishes loading - and its arguments are similar to what you're using already.

    Also check for general JavaScript errors in the page - this is often seen by an error icon in the browser's status bar. Sometimes a JavaScript error will hold up or disturb unrelated elements on the page.

    0 讨论(0)
  • 2020-12-06 19:18

    Hai sridhar, I found an answer for your prob

    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);
    
    0 讨论(0)
提交回复
热议问题