-
Need for a way to execute SP, close window and display alert..............
Fellow programmer, I am new to ASP.NET and am in need of some advice. I am executing a Stored Procedure in the OnInit function and after it executes, I would like to close the window and display an alert message. Below is the code snippet which executes the stored procedure and closes the window. But I am not able to display the alert message.
protected override void OnInit(EventArgs e)
{
sAction = Request.QueryString["action"];
String sId = Request.QueryString["id"];
int iId = sId == null ? 0 : int.Parse(sId);
this.EditFarmID = iId;
DeleteFrmEntryDS(this.EditFarmID);
ClientScript.RegisterStartupScript(GetType(), "alert", "<script type=\"text/javascript\">window.opener=self; window.close();</script>");
}
}
If I include the Alert towards the end of my JS, then the alert displays, but the window does not close. Its because of the timing.
I am trying to reduce creating extra asp pages and would prefer to do everything in fewer amounts of asp pages needed. That’s why I am doing the processing of my SP in the same page as the form.
Any help would be appreciated.
-
This seems to work:
ClientScript.RegisterStartupScript(GetType(), "alert", "<script type=\"text/javascript\">window.alert(\"Hello, world\"); window.opener=self; window.close();</script>");
Phil Weber
http://www.philweber.com
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
-
Phil thanks for the quick reply. I have actually tired your suggestion too but that does not work like I want it to. I guess I wasn't absolutely clear. Basically by including the alert at the beginning of the javascript, it does appear but my webpage form also stays hanging in the background. This is what I absolutely do not want to display. What I want is when my delete SP executes and completes, I want the form window to close immediately, and after that display the alert. With your suggestion, my form window will only close after the ok button on the alert is clicked. I hope I am making sense.
Here is a quick flow of what I am trying to do:
I have a simple form myasp.aspx and this page does two things. One is to display the form and the other to execute a SP based on querying the URL for a specific flag. Something like this :
http://www...../CPN/myasp.aspx?action=D&id=123
so, when I want the myasp.aspx page to call my SP then this page’s OnInit function calls the SP and used the passed id. And after the SP is executed I want this page to close immediately. Since displaying the form is not required. And I want to show a quick alert (“Your entry has been deleted”)
-
I don't think it's possible to do what you want to do. I would display the confirmation message on the page itself rather than using an alert.
Phil Weber
http://www.philweber.com
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
Similar Threads
-
Replies: 0
Last Post: 08-18-2006, 05:25 AM
-
By Usha.R in forum ASP.NET
Replies: 1
Last Post: 02-14-2006, 03:30 AM
-
By Rachel Ernst in forum Architecture and Design
Replies: 1
Last Post: 02-13-2001, 01:15 PM
-
By TC in forum VB Classic
Replies: 8
Last Post: 09-26-2000, 02:34 AM
-
By TC in forum VB Classic
Replies: 0
Last Post: 09-25-2000, 09:06 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|