Link to home
Start Free TrialLog in
Avatar of dreamchaser23
dreamchaser23

asked on

Buttons disappear when Alert messages are displayed.

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,
Regards,
DreamChaser.
Avatar of VincentPuglia
VincentPuglia

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.  
Avatar of dreamchaser23

ASKER

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.
Regards
DreamChaser
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
like
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');" />

Regards
Renju



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!

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

Regards
DreamChaser
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
Regards
DreamChaser
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.
Regards
DreamChaser
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?

Thanks,
DreamChaser
ASKER CERTIFIED SOLUTION
Avatar of VincentPuglia
VincentPuglia

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I had a good look at the great article, vincent..
thanks...
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.

Computer101
EE Admin
VincentPuglia fullly deserves the points...
really apologize for the delay