• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 423
  • Last Modified:

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.
0
dreamchaser23
Asked:
dreamchaser23
1 Solution
 
VincentPugliaCommented:
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.  
0
 
dreamchaser23Author Commented:
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
0
 
VincentPugliaCommented:
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')
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
renjurdevanCommented:
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



0
 
dreamchaser23Author Commented:
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
0
 
dreamchaser23Author Commented:
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
0
 
VincentPugliaCommented:
Wish ya luck, mate!  Keep us posted.
0
 
dreamchaser23Author Commented:
Thanks Vincent.
Appreciate your concern!
Will definitely do =)
0
 
dreamchaser23Author Commented:
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
0
 
dreamchaser23Author Commented:
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
0
 
dreamchaser23Author Commented:
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
0
 
VincentPugliaCommented:
Hi,
   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)

0
 
dreamchaser23Author Commented:
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.
0
 
VincentPugliaCommented:
you're welcome
0
 
Computer101Commented:
Forced accept.

Computer101
EE Admin
0
 
dreamchaser23Author Commented:
VincentPuglia fullly deserves the points...
really apologize for the delay
0
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.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now