ModalPopup Abilitites

Last post 09-02-2006 5:18 PM by Ted Glaza [MSFT]. 12 replies.

Sort Posts:

  • ModalPopup Abilitites

    08-27-2006, 4:27 AM
    • Loading...
    • a2mawani
    • Joined on 03-04-2006, 3:53 AM
    • Posts 34

    Hi All,

     

    I’m having a few problems using the ModalPopup control and was wondering if anyone could help me out. Here goes:

     

    1)      If I want to use a user control as the popup control when using a modalpopup extender, is that possible? I have seen other people asking it but it doesn’t seem to be resolved whether one can specify the Ok Control and Cancel control as two controls within (children of) the usercontrol.

    2)      Is it possible to have more than one ok or cancel control for the popupmodal extender?

     

    Thanks!

     

    aloo

     

  • Re: ModalPopup Abilitites

    08-28-2006, 4:21 PM

    1. Should be possible - especially if you handle the ResolveControlID event to find the controls yourself.

    2. Not by default, but you should be able to add additional OK buttons with onclick= handlers that simply click the "real" OK button. Similar for Cancel.

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: ModalPopup Abilitites

    08-29-2006, 8:10 AM
    • Loading...
    • a2mawani
    • Joined on 03-04-2006, 3:53 AM
    • Posts 34

    1. Works great, thanks.

    2. How do you do that specifically in code? How do you programatically click a button from the event handler of another?

  • Re: ModalPopup Abilitites

    08-29-2006, 2:59 PM
    Hi a2mawani,

    To programatically click a button you just get a reference to it and call its click function (i.e. $('MyOKButton').click(); is all it should take).

    Thanks,
    Ted
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Filed under: ,
  • Re: ModalPopup Abilitites

    08-29-2006, 3:12 PM
    • Loading...
    • a2mawani
    • Joined on 03-04-2006, 3:53 AM
    • Posts 34

    The above is javascript, yes? Sorry I'm new to the platform, how do you call that code from a server side event handler for the other buttons?

     I.e. server side event handler for ButtonA and ButtonB have to call click for ButtonC

  • Re: ModalPopup Abilitites

    08-29-2006, 3:28 PM

    Hi a2mawani,

    Yes, the code I showed was JavaScript.  If you're doing it all on the server, then couldn't ButtonA's event handler just call ButtonC's event handler (passing the same event args and passing ButtonC as the source)?

    Thanks,
    Ted

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: ModalPopup Abilitites

    08-29-2006, 3:33 PM
    • Loading...
    • a2mawani
    • Joined on 03-04-2006, 3:53 AM
    • Posts 34
    Not sure how that works because I'm using this for the ModalPopup...... Basically I wanted to have 3 different ok buttons. So i created a 4th button that's hidden and I'll set the OkControilId of the ModalPopupExtender to the hiddenButton. I don't have a event handler for the hiddenButton because it's not really doing anything. Also, I thought that the modalPopupExtender intercepts the buttons click event to do its own stuff, will simply creating a handler for the hiddenButton and calling it do the trick?
  • Re: ModalPopup Abilitites

    08-30-2006, 3:18 PM
    Hi a2mawani,

    I'm not really following what you're doing here...  perhaps taking a look at http://forums.asp.net/thread/1383860.aspx could help you out (especially David's suggestion).  It should let you do whatever you want with your three buttons and then close the modal popup when they're done.

    Thanks,
    Ted
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Filed under:
  • Re: ModalPopup Abilitites

    08-31-2006, 4:25 AM
    • Loading...
    • a2mawani
    • Joined on 03-04-2006, 3:53 AM
    • Posts 34

    I'm sorry, you're right I havent been very clear as to what I'm trying to accomplish. Let me see if I can explain it better:

    1) I have a single aspx page with 5 button controls labelled Button1..Button5

    2) The user must be logged in to the site in order to use these buttons. So when a button is pushed, if the user is NOT logged in, I would like to display a modalpopup allowing the user to:

    A) Login by filling in fields and clicking on a button named loginButton

    B) Register by filling in fields and clicking a button named registerButton

    C) Cancel the operation and dismiss the popup using a button named cancelButton

     

    What I have So Far:

    I) The popup I will be displaying is a user control containing all the controls for logging in/registering

    II) I can bind one modalpopupExtender to a single Button (Button1) as the targetcontrol and to my usercontrol as the popupcontrol.

    III) I can handle the ResolveControl event of the modalPopupExtender to find the cancelCancel button on my usercontrol because there is only one.

    IV) I have the logic to log users in and register them in the apporpriate server side click handlers of the login and register button respectively.

    V) The user control (which is what gets popped up) contains and update panel so that all the server calls happen async so the popup isnt dismissed once these buttons are pressed and the server side logic is performed.

     

    What I can't do:

    a) Bind the modalPopupControl so that the popup appears when any of Button1..Button5 is pressed. A requirement however, is that each button must perform serverside code to check the current login status BEFORE opening the modalPopup if necessary

    b) Allow the loginButton or the registerButton dismiss the popup dialoge once the user has correctly logged in or registered. Another requirement of course is that both these buttons must perform server side code to check that the information entered was correct/valid.

     

    Current Temporary Solution:

    I currently only have a solution for problem b which is to allow the loginButton and registerButton to perform a Response.Redirect('currentPageUserIsOn.aspx") at the end of the server side onClick handlers. Obviously this isnt ideal becuase the screen is refreshed.

     

    I know that was a lot but if any one has any ideas for overcoming these issues, please let me know! Thanks!

     

    -aloo

     

  • Re: ModalPopup Abilitites

    09-01-2006, 4:10 PM

    Hi aloo,

    I think I better understand what you're trying to do now.  I think the answer to your first problem is to create a copy of the ModalPopupProperties for each of your buttons.  All the server code, controls, etc., should be the same with just the TargetControlID varying.  To solve your second problem, I would again recommend taking a look at http://forums.asp.net/thread/1383860.aspx.  Since you don't have a specifc button to close the popup with server side, you can use RegisterStartupScript to write some code that will close it when either a successful login or registration takes place.

    Thanks,
    Ted

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Filed under:
  • Re: ModalPopup Abilitites

    09-01-2006, 7:33 PM
    • Loading...
    • a2mawani
    • Joined on 03-04-2006, 3:53 AM
    • Posts 34
    I'm not sure if that will work because I only want the buttons (1 to 5) to show the modalPopup if the user is not logged in which will require some server side handling once the button is clicked to check the sign in status.
  • Re: ModalPopup Abilitites

    09-02-2006, 2:23 AM
    • Loading...
    • a2mawani
    • Joined on 03-04-2006, 3:53 AM
    • Posts 34
    Is it possible to do the signed in check on Page_Load and then depending on the results, add the neccesserary ModulPopupProperties to the extender control?
  • Re: ModalPopup Abilitites

    09-02-2006, 5:18 PM
    Hi aloo,

    Yes - you can create the extender properties you need dynamically in OnLoad.  Check out FAQ Item #13 for more details.

    Thanks,
    Ted
    This posting is provided "AS IS" with no warranties, and confers no rights.
Page 1 of 1 (13 items)
Microsoft Communities