Results 1 to 7 of 7

Thread: Need to prompt user before navigating away from a page, and perhaps stay on page

  1. #1

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    My Mustang GT
    Posts
    4,562

    Need to prompt user before navigating away from a page, and perhaps stay on page

    I need to check information the user has entered on a page against what I have in my database to see if he is entering duplicate data. It is up to him if he wants to proceed or not. I just need to alert him.

    The problem is I don't own the button that he clicks so I can't hook up a javascript confirm to the button click. I am running within vendor code. I have an "override PageLoad()" procedure where I can test what page they're currently on. If they are on page "EditForm.aspx" and would normally navigate to "UserFinish.aspx" without any custom code of mine "interfering", I want to test what they've entered on EditForm.aspx and present them with a popup if they've entered duplicate info, and if they click OK button then proceed to UserFinish but if they click Cancel then stay on EditForm.

    I've googled and found some things that might work, but it's usually followed by a caveat saying "do the following, but I don't recommend it", so I just wanted to ask for a way that is recommended. Thanks.
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  2. #2
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    Re: Need to prompt user before navigating away from a page, and perhaps stay on page

    Does it have to be a message box? I've found that trying to work with MessageBoxes are a pain in ASP.NET. I just use hidden buttons and when there's an exception, I show the buttons.
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  3. #3

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    My Mustang GT
    Posts
    4,562

    Re: Need to prompt user before navigating away from a page, and perhaps stay on page

    I'm not sure what you mean exactly, but I don't have a page on which to hide any buttons. I just have a C# class that's compiled and the DLL that's created gets put in the deployment, and the vendor code will call it simply because it exists and I've defined a path to it. But the vendor page calls my code. I don't have a page.
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  4. #4
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    Re: Need to prompt user before navigating away from a page, and perhaps stay on page

    Quote Originally Posted by MMock View Post
    I'm not sure what you mean exactly, but I don't have a page on which to hide any buttons. I just have a C# class that's compiled and the DLL that's created gets put in the deployment, and the vendor code will call it simply because it exists and I've defined a path to it. But the vendor page calls my code. I don't have a page.
    Oh. I see what you mean. Hm... well, wouldn't you just create a method that returns a boolean and then allow them to handle it how they choose?
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  5. #5
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: Need to prompt user before navigating away from a page, and perhaps stay on page

    Quote Originally Posted by weirddemon View Post
    Oh. I see what you mean. Hm... well, wouldn't you just create a method that returns a boolean and then allow them to handle it how they choose?
    I concur to that.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  6. #6

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    My Mustang GT
    Posts
    4,562

    Re: Need to prompt user before navigating away from a page, and perhaps stay on page

    A server method or a client method?

    And returns a boolean to where?
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  7. #7
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: Need to prompt user before navigating away from a page, and perhaps stay on page

    If you use webservice then fix up client method.If you use webserver then fix up a server method.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width