7

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 follows:

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

When the alert box appears is comes with a white background. I clicked on ok button in that alert box but the page is not going back to the previous page it is showing the same white space.

Can you solve the problem.? If you not understand i will explain clearly.

In local it is working fine but when i update in online it is not working.

8
  • This is not clear "the page is not going back to the previous page it is showing the same white space can you solve the problem" Commented Dec 15, 2009 at 7:36
  • Try a return true; after your alert and see what happens Commented Dec 15, 2009 at 8:02
  • hi Mr.Pandiya Chendur where should i write the code return true Commented Dec 15, 2009 at 8:08
  • ok i understand Mr. Pandiya chendur i will try and let u inform ok Commented Dec 15, 2009 at 8:17
  • Mr.Pandiya chendur it is giving error like this. i wrote the code after the ClientScript.RegisterClientScriptBlock(GetType(), "sas", "<script> alert('Inserted successfully');</script>", false); return true; it is giving the error like.... 7: Since 'Subadmins_uploadvideos.insertVideos()' returns void, a return keyword must not be followed by an object expression Commented Dec 15, 2009 at 8:23

3 Answers 3

16

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);
Sign up to request clarification or add additional context in comments.

6 Comments

No Pandiya Chendur my name is sasidhar
No Mr.Pandiya Chendur when i change false to true the alert message is not coming
button or linkbutton or image button
Actually i remove the ClientScript.RegisterClientScriptBlock(GetType(), "sas", "<script> alert('Inserted successfully');</script>", false); and write the code response.write("<script> alert('Inserted successfully');</script>"); and it is working fine Thank you for response and spend time on my problems
make sure that response.write will be an issue in a web form application while you deploy to server... Any how you made it work
|
1

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.

7 Comments

No Mr.jdk i am not getting any javascript erros in the page
i am not going to my page where i upload the video
Do you need to redirect to another page after alert is dismissed by user?
No Mr.Jdk. see, suppose default.aspx is there where i write the code to upload the video, when video upload is over i write the ClienetScript.RegisterStartupScript() if video is uploaded one alert box comes in a white background page when i click on Ok of the alert box it is not going back to default.aspx page, it is remain in the white background page i think you get my problem now
Can you provide a link to it?
|
1

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)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.