Link to home
Start Free TrialLog in
Avatar of quest_capital
quest_capital

asked on

Call an Alert box with ASP

I want to call an alert box with asp with out distrubing the page.
I can do it with the code below but I know that there has to be a better way

<%
Response.Write("some code")
%>
<script language = JavaScript>
      alert('Alert');
</script>
<%
Response.Write("some code")
%>

Let me know if you know of a better way than the above code or just doing a Response.Write("Alert").
Avatar of quest_capital
quest_capital

ASKER

The code above turns the page white when it gets to the alert box.
what do you mean by not disturbing tha page?
Avatar of raj3060
>>The code above turns the page white when it gets to the alert box.

Reason is that you need to run this on server..

try this:

<%
Response.Write("some code")
%>
<p>I am here.....</p>
<script language = JavaScript>
     alert('Alert');
</script>
<%
Response.Write("some code")
%>
<p>and I am here too.....</p>
You can use a vbscript pop up when the page loads:

<Script language="vbscript">
msgbox "Alert"
</Script>
ASKER CERTIFIED SOLUTION
Avatar of davidlars99
davidlars99
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
or mix them up

<script language=Javascript>

   var ie=(navigator.userAgent.toLowerCase().indexOf("msie")!=-1?true:false);

   function check(){
       if(ie)
            if(document.body.readyState=="complete")
                 setTimeout('alert("complete")', 555);
            else
                 setTimeout('check()', 25);
        else
            setTimeout('alert("complete")', 600);
   }

   check();
</script>
You cannot have an alert in the middle of an ASP script and have it execute immediately.  All ASP scripting is evaluated and processed before the client gets the code and then the client renders the results.  At that point the alert, would execute, if not in a function, as the page loads.