Hi there,

I am using a javascript command to show a message box in my web application since the MessageBox.Show() command won't work. The message box appears, however, it seems like it has navigated out of the web application showing the default grey background.

How do I modify the code so that the message box appears in the same page where the rest of the information is.

Response.Write(@"<script language='javascript'>alert('This field cannot be empty')</script>");

Moreover, each time I click a button or the calendar at the bottom of the page, I get moved upwards, at the top part of the web app and away from the button in question.

Thank you in advance.

Kind Regards,

croussou

Recommended Answers

All 3 Replies

So you want your alert box to be part of the page, not above it like the javascript alert box? You can do this by either including a div with the error message in your page and either:
- toggling it visibility will you want it to display

- initially placing it off screen through it x coordinates and moving it into the correct location when you want to display it.

This of course assuming a label with text won't suffice for what you need. For highlighting inputs that are required you can always use required field validators placed beside the input.

Thank you for the replies guys, much appreciated.

Kind Regards,

croussou

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.