popup message box in asp.net

this is really strange
if i put this code right in pageload function, it will work fine. but if i put it in a subroutine and then call that sub in page load, it won't work at all. could you tell me why
                    ClientScript.RegisterStartupScript(Me.GetType(), "AlertBox", "alert(Error Found');", True)
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hi StewSupport,

Can you post the rest of your PageLoad and your Subroutine?
StewSupportAuthor Commented:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load  
end sub

private sub displaypopup()
   ClientScript.RegisterStartupScript(Me.GetType(), "AlertBox", "alert(Error Found');", True)
end sub
The code seems to work fine on my machine.  I tested both 2.0 and 3.0 and in the private sub it worked just fine.  Is there other code in the project or just this code?
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

Same on mine, it works fine. No idea why it's not working on yours.
Do you have any other code that is in these two functions?   When the page loads is there a javascript error being generated?  What is the difference in code output to the window?  Does the script get written?
StewSupportAuthor Commented:
no nothing just those lines.
Are you running this locally, or on a web host or server?   What version of Visual studio and the .net framework?
In your Alert function you're missing a quote before "Error".

ClientScript.RegisterStartupScript(Me.GetType(), "AlertBox", "alert(Error Found');", True)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.