locked
how can i get javascript popup window's 'OK' or 'Cancel' button event in C# RRS feed

  • Question

  • Hi all,

    I am trying to access SQL server DB through custom webpart, before connecting to DB
    I wanted to display a pop up meassage"Wanted to connect DB", if user click OK button, then there should be
    connection with dB, if user click Cancel -no connection.

    And I can display java script popup window, but how can i get 'OK' button event in c# to connect DB or 'Cancel' event to stop execution.


    Or help me on this, how can i get similar in C#.


    arun singh
    Monday, December 7, 2009 6:38 AM

Answers

  • Having a javascript to achieve this functionality would be tedious. The challenging part would be how do you give the control back to the web part, once the OK button is clicked. I'd recommend you to have this modal pop-up kind of functionality inside web part UI itself by having some sort of panels. When the user clicks OK or cancel, hide or show your main panel, that does the actual job of connecting to DB and performing the actual data access.


    Sundar Narasiman
    Monday, December 7, 2009 7:36 PM

All replies

  • hi arun,

    If user clicks "Cancel" return false from your javascript .
    Otherwise on clicking "Ok" return true and connection would continue.

    Thanks.
    Gaurav Nanda
    • Proposed as answer by f00z Monday, December 7, 2009 7:51 PM
    Monday, December 7, 2009 8:03 AM
  • Having a javascript to achieve this functionality would be tedious. The challenging part would be how do you give the control back to the web part, once the OK button is clicked. I'd recommend you to have this modal pop-up kind of functionality inside web part UI itself by having some sort of panels. When the user clicks OK or cancel, hide or show your main panel, that does the actual job of connecting to DB and performing the actual data access.


    Sundar Narasiman
    Monday, December 7, 2009 7:36 PM
  • Hi all,


    Sorry for late reply, till yet did not applied Sundar's suggestion, but seems that it will work.

    Thanking you all for kind support.
    arun singh
    • Marked as answer by Sonu888 Thursday, December 10, 2009 12:55 PM
    • Unmarked as answer by Sonu888 Thursday, December 10, 2009 12:55 PM
    Thursday, December 10, 2009 12:55 PM