We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


Buttons disappear when Alert messages are displayed.

Medium Priority
Last Modified: 2012-06-27
In my webform, when the user clicks on Save button, I display the prompt that the data was saved using this code:
In aspx.cs file:
errMes.InnerHtml = "<script language='javascript'>alert('" + "Data Saved" + "')</script>";

But when this alert message pops up on the screen, some of the buttons in the page, disappear. They re-appear after I click on OK button on the alert message.
Could you please let me know what has to be done to avoid this issue.

Thanks a lot,
Watch Question

I presume you mean buttons that directly below the alert message?  If so, afaik, there is nothing you can do short of writing a semi-transparent div that delivers the same message.  


Hi Vincent
Thank you so much for your reply, mate
The buttons aren't present directly below the alert message but else where like Logout Button etc.
But when the alert message pops up those buttons disappear strangely and re-appear after I click on OK button of the alert message.
It would be great if you can let me know how I go about doing it.

Thanks again for your reply.
ok if the buttons aren't near the alert message, then I have to assume it's because of bandwidth or whatever errMes does.
  What is errMes?  a vb element?  are you going back to the server?  Why don't you simply insert the alert message within your button's onclick event?
  <input type='button' value='save' onclick='alert("Data Saved"); whateverOtherCodeIsFired')
When you Click a button you are posting your request to server !! For showing an alert the way you chose is not correct !!

If you want to show the message after saving Data Better put in a label
lblSave.Text = "Data Saved";

not as a alert(); Becoz when going for a alert message server will not render all controls until u clicked OK button!! That is the reason you are missing few Controls on the page before pressing OK!

if you want to show the message before data being saved you can  use like

<input type='button' value='save' onclick="alert('Data about to save');" />



Thanks a lot Renjurdevan.
Appreciate your help.
I'll try the solution that you've posted and will get back to you..
Thanks again, mate!



Hi Vincent,
Thank you once again for your comment.
I'll try to prompt the alert mesg in the button's onclick event.

Wish ya luck, mate!  Keep us posted.


Thanks Vincent.
Appreciate your concern!
Will definitely do =)


Hi Renjur,
Seems that I should not prompt the msg in a label, it has to be thro' alert mesg only.
Thanks for the comment once again and sorry for getting back to you late


Hi Vincent,
I didn't get a chance to look at the soln, you had posted dude.
My manager gave me high priority tasks, that I wasn't able to concentrate on this.
I'll let you know within 1 or 2 days.
Thanks mate.


Hi Vincent,
I have to do some validations on the data before saving them.
So I have to put the alert code only in the server side, and based on the data entered by the user, I have to say appropriate error mesgs like "Data Saved" "Nothing to save" "The values on this textbox should be greater than the values on this text box" etc.
This needs me to access the database to check for unsaved data, right?
So I can only add the alert mesg in Server side, right?

   sorry, got tied up in real life.
Ok, my current understanding of your prob:
 your boss insists on server side messages.
    My opinion: he's living in an IBM 360 world.  If you are going to execute (imho) meaningless/redundant/moot messages, they should be done on the clientside (it's faster).  You couild attach an onclick event that says: "Data is being sent/saved"  and if it fails validation on the server side, then execute your "Data was not valid & not saved" message with asp.(at which point you also have to redraw your page in order to highlight the failed input(s). Of course if you are not going to validate the entire input before executing your 'will not save' message, then you should be doing your validation client side as well.
insofar as validation & checking the db:

No, you do not need to check the db for unsaved data. If data fails, your db is never  called.  Your validation should set flags that tell you & the user which input fields fail and why.  For an example of validating client side, see http://members.aol.com/grassblad/html/validForm.html   It's a script/tutorial I wrote up years ago ... not great, but the concepts are still valid (even for server side validation)

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


I had a good look at the great article, vincent..
Learnt quite a lot :)
Didn't have time to implement this, as I had some critical tasks for our recent PROD move.
I'll try this and get back to you ASAP.
Thanks again for the nice article, Vincent.
you're welcome
Forced accept.

EE Admin


VincentPuglia fullly deserves the points...
really apologize for the delay
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.