I attched file. like this it is coming. i want my project form as background in place of white screen.iam using update panel also. in cs iam writing this code for alert message
The way you had it originally, your alert was called at the top of the page, before anything else was rendered.
With the RegisterStartupScript, "The script block added by the RegisterStartupScript method executes when the page finishes loading but before the page's OnLoad event is raised."
Perhaps you draw a lot of your page in the OnLoad event?
Anyway, you'll want to arrange it so that the alert is called AFTER you set all the important background.
If your OnLoad event emits the important stuff, you'll want to emit your script AFTER.
Yes.Please give me solution for that one.With out refreshing that alert should come.Iam using update panel also.please help me it is urgent
Jens Fiederer
This is what you would expect when you run the javascript too early - it pauses until you complete the alert by pressing OK, then it finishes rendering.
You do NOT want to run that Javascript until your page is completely rendered.
It might be best to emit it as a function definition and adding it as an onload as in here:
Create a JavaScript, say called "displayAlert()" like this:
function displayAlert()
{
alert("invalid file");
return true;
}
then change your code to this:
ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "alert", "displayAlert()", true);
The "return ture" in the JavaScript should let your page display after the alert pops up.
Let me know if it works for you.
Jens Fiederer
He says it already DOES display after the alert pops up.
He wants it to finish displaying BEFORE the alert pops up, which means he has to complete everything that needs to be done before triggering that alert.
Using
ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "alert", "displayAlert()", true);
triggers the alert BEFORE the page is rendered.
One needs to know everything that is involved in rendering the page (he has indicated at least a part of this is done using AJAX, which could happen AFTER the page is already completely sent over).
The alert message is a nice way to see where you ARE, but in the end it needs to be triggered AFTER the last significant display operation has occurred.
Without full access to your code it is not possible to say exactly where that is - if you are displaying pretty much a blank page, and later filling in with AJAX, you have to time the alert carefully.