views:

1152

answers:

2

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.

A: 

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.

John K
No Mr.jdk i am not getting any javascript erros in the page
Surya sasidhar
i am not going to my page where i upload the video
Surya sasidhar
Do you need to redirect to another page after alert is dismissed by user?
John K
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
Surya sasidhar
Can you provide a link to it?
John K
Sorry Mr.Jdk actually i am in office it is not possible, it is confidential
Surya sasidhar
Any way Mr.Jdk thank you for response spend time on my problem thank you
Surya sasidhar
+2  A: 

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);
Pandiya Chendur
No Pandiya Chendur my name is sasidhar
Surya sasidhar
No Mr.Pandiya Chendur when i change false to true the alert message is not coming
Surya sasidhar
ok sashi try the secon one
Pandiya Chendur
are you calling it on a button click... Can i know its type...
Pandiya Chendur
button or linkbutton or image button
Pandiya Chendur
Ya it is working Mr. Pandiya Priya
Surya sasidhar
What you did to get it working...
Pandiya Chendur
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
Surya sasidhar
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
Pandiya Chendur
Ok i will take care other wise i will go for other option. I think you understand my problem. if you get the solution send the response thank you for your response. i think u r an India right.
Surya sasidhar
ya tamilan from coimbatore
Pandiya Chendur
ok nice to meet you Pandiya
Surya sasidhar