?
Solved

Buttons disappear when Alert messages are displayed.

Posted on 2007-07-19
17
Medium Priority
?
411 Views
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,
Regards,
DreamChaser.
0
Comment
Question by:dreamchaser23
16 Comments
 
LVL 15

Expert Comment

by:VincentPuglia
ID: 19525668
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
 

Author Comment

by:dreamchaser23
ID: 19526178
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
 
LVL 15

Expert Comment

by:VincentPuglia
ID: 19526428
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 12

Expert Comment

by:renjurdevan
ID: 19528868
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
 

Author Comment

by:dreamchaser23
ID: 19530446
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
 

Author Comment

by:dreamchaser23
ID: 19530457
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
 
LVL 15

Expert Comment

by:VincentPuglia
ID: 19531393
Wish ya luck, mate!  Keep us posted.
0
 

Author Comment

by:dreamchaser23
ID: 19532288
Thanks Vincent.
Appreciate your concern!
Will definitely do =)
0
 

Author Comment

by:dreamchaser23
ID: 19776515
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
 

Author Comment

by:dreamchaser23
ID: 19776524
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
 

Author Comment

by:dreamchaser23
ID: 19776619
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
 
LVL 15

Accepted Solution

by:
VincentPuglia earned 2000 total points
ID: 19779972
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
 

Author Comment

by:dreamchaser23
ID: 19955360
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
 
LVL 15

Expert Comment

by:VincentPuglia
ID: 19955637
you're welcome
0
 
LVL 1

Expert Comment

by:Computer101
ID: 20343721
Forced accept.

Computer101
EE Admin
0
 

Author Comment

by:dreamchaser23
ID: 20344155
VincentPuglia fullly deserves the points...
really apologize for the delay
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses
Course of the Month15 days, 12 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question