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)
StewSupportAsked:
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.

Juan_BarreraCommented:
Hi StewSupport,

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

private sub displaypopup()
   ClientScript.RegisterStartupScript(Me.GetType(), "AlertBox", "alert(Error Found');", True)
end sub
0
jjardineCommented:
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?
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

Juan_BarreraCommented:
Same on mine, it works fine. No idea why it's not working on yours.
0
jjardineCommented:
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?
0
StewSupportAuthor Commented:
no nothing just those lines.
0
jjardineCommented:
Are you running this locally, or on a web host or server?   What version of Visual studio and the .net framework?
0
tiagosalgadoCommented:
In your Alert function you're missing a quote before "Error".

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

0

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
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.