Need for a way to execute SP, close window and display alert..............


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Need for a way to execute SP, close window and display alert..............

Hybrid View

  1. #1
    Join Date
    Feb 2007
    Posts
    2

    Cool 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.

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    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!

  3. #3
    Join Date
    Feb 2007
    Posts
    2
    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”)

  4. #4
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    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

  1. Replies: 0
    Last Post: 08-18-2006, 05:25 AM
  2. Regarding closing a pop window
    By Usha.R in forum ASP.NET
    Replies: 1
    Last Post: 02-14-2006, 03:30 AM
  3. New Target Window for links Re: Help- URL HELP-
    By Rachel Ernst in forum Architecture and Design
    Replies: 1
    Last Post: 02-13-2001, 01:15 PM
  4. child window - is it or isn't it?
    By TC in forum VB Classic
    Replies: 8
    Last Post: 09-26-2000, 02:34 AM
  5. child window - is it or isn't it?
    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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center