?
Solved

How to use the Alert Message with VB 2005.net

Posted on 2007-10-18
9
Medium Priority
?
443 Views
Last Modified: 2013-11-26
I have a form that updates a database when the user clicks btnUpdate.
After the user clicks the update button and the database is updated I want to send the user a message saying the database was updated. If I put an alert in the OnClientClick the alert pops up before the database is updated.
Does anyone have an example of how to sent a message after the database is updated
Thanks
0
Comment
Question by:whiwex
  • 5
  • 4
9 Comments
 
LVL 65

Expert Comment

by:RobSampson
ID: 20106332
Can you place the Alert command *after* the command runs the database update?  The code should wait for the update command to finish executing, if it's executing synchronously, and then execute the Alert statement.

Regards,

Rob.
0
 

Author Comment

by:whiwex
ID: 20106602
Rob
My problem is after the database is update I send the user to another page. The alert doesn't appear if I do the server.transfer

 ClientScript.RegisterClientScriptBlock(Me.GetType(), "ThankYou", scriptString.ToString)
  Server.Transfer("~/account forms/update database.aspx")
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 20106618
Then are you able to put the alert into the "update database.apsx" page, after the update?

Regards,

Rob.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:whiwex
ID: 20106642
Yes
In the Update button click I put the alert. It works fine but it will not display if I have the server.transfer at the end of the Update Button click event. I don't want the server.transfer to happen until after the user clicks OK in the alert window.
Thanks
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 20106683
Oh, I see....it's because you're using client side code for the message box, which isn't waiting to finish, then server side with the transfer.....can you change the transfer to server side?

Regards,

Rob.
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 20106690
Like if in your ASP you include some Java code:

' about to show message and redirect
ShowMessage("Thank You")

Sub ShowMessage(sMessage)
%>
<script>
alert("<%= sMessage %>" )
document.location="xyz.asp"
</script>
<%
End Sub

Regards,

Rob.
0
 

Author Comment

by:whiwex
ID: 20106762
Rob
I can't get this to work
Thanks
0
 

Author Comment

by:whiwex
ID: 20106776
Rob
I'm just learning this
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 2000 total points
ID: 20106937
Sorry, I don't much about it either.....but let's try.....I'm assuming the two lines you posted are in the <% and %> tags of the asp code, so

In place of this:
<%
...
...
ClientScript.RegisterClientScriptBlock(Me.GetType(), "ThankYou", scriptString.ToString)
  Server.Transfer("~/account forms/update database.aspx")
...
....
%>

Try this

<%
....
....
%>
<script>
alert("<%= sMessage %>" )
document.location="http://yoursite/account forms/update database.aspx"
</script>
<%
....
.....
%>



Where you should change the website address to the full path of the website, as seen from the client side....

Regards,

Rob.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Screencast - Getting to Know the Pipeline
Suggested Courses

840 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