Click here to Skip to main content
15,896,466 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
im c# starter
i put one messagebox in my project but it is always minimize and the user should click on it to come up!
what should i do?

What I have tried:

MessageBox.Show("نام کاربری یا رمز عبور اشتباه!");
Posted
Updated 25-Jun-16 22:32pm

Don't use MessageBox.Show on ASP.NET. Use this one:
Page.ClientScript.RegisterStartupScript(this.GetType(), "scriptkey", "<script>alert('your message');</script>");
 
Share this answer
 
You cannot use MessageBox in ASP.NET, because you don't want to try to show a modal box on the server side. :-)

Using JavaScript alert is also usually not good; not only it is badly inflexible, but you cannot style it or make its look and behavior independent of the OS and particular browser; for production quality applications, this is not good enough.

For further explanation of the choice of the solution for the dialog-like behavior, please see my article Modal Popup From Scratch.

It would be much better to develop modal-like behavior inside a Web page, and do it fully locally, with JavaScript. The first solution would be this: https://jqueryui.com/dialog[^].

Also, there are many 3rd-party jQuery plug-ins, collectively known as "modal popup", with different effects, such as transitions, and, notably, dimming of the rest of the page. Please see: http://bfy.tw/AJH[^].

If you need to learn jQuery, please see:
http://en.wikipedia.org/wiki/JQuery,
http://jquery.com,
http://learn.jquery.com,
http://learn.jquery.com/using-jquery-core,
http://learn.jquery.com/about-jquery/how-jquery-works (start from here).

The alternative would be the implementation of modal popup from scratch, which I explained in detail in my article referenced above.

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900