Wednesday, March 21, 2012

Need Help With The ModalPopup Control

i have a few questions about the ModalPopup control. i was wondering if somebody more experienced could help me. I only installed Atlas yesterday - Im a bit of an Atlas newbie - so i apologise in advance if any questions sound naive.

1. when my page first loads the ModalPopup control is visible for a second or so then disappears. This has been mentioned before here:http://forums.asp.net/thread/1363694.aspx. My manager will not accept this as it looks 'odd'. Is there a fix for me?

2. when my ModalPopup control pops up the dropdownlists within the <div> below it disappear. This has also been mentioned here:http://forums.asp.net/thread/1363694.aspx. I tried re-referencing the ControlToolkit dll's as this previous poster suggested but it still doesn't work for me. Am i missing something?

3. my ModalPopup control contains a user control which is in effect a search facility. this search facility needs to post back in order to populate its grid with results. when my button within the ModalPopup control causes a post back the ModalPopup control is hidden after the post back. Can I fix this?

4. Finally, is the ModalPopup control only designed for more simple situations like the paragraph selector in your examples? Am i pushing it too hard by trying to put a more complex user control inside it that itself needs to do multiple post backs? Should I be looking at other alternatives?

Thanks for any help!

Hi Wee Bubba,

Let's go through your questions:
1. If you set "display: none" in theStyle attribute of yourModalPopup, you won't see it when it loads.
2. The drop down lists are intentionally hidden - if we didn't hide them then they would appear on top of the transparent overlay and you could manipulate them. This is a problem with IE and certain controls. A lot of people on the forums have discussed working around this by using an IFrame - and I think someone might even be working on incorporating that into the Toolkit.
3. TheModalPopup won't be visible on a postback. If you want to use it with postbacks, I would recommend wrapping the contents of the popup in anUpdatePanel.
4. You should be able to get away with anything inside aModalPopup that you can inside anUpdatePanel - which means you can do an awful lot inside of it.

Thanks,
Ted

hi ted, and thanks for your comprehensive replies. it is reassuring to know that there is such a helpful community for atlas, and this is one of the reasons why i have chosen Atlas over some of its counterparts.

i will endeavour to implement your suggestions and will come back to you if i get stuck again (if thats ok).

onwards and upwards!


hello again. i have been wrestling with this ModalPopup control all day. i am tantalisingly close but i have a few more questions to hit you with if that is ok. if you would be so kind!

it is perhaps helpful for me to describe what i am trying to achieve on this web page. basically, when my users are inserting or editing a row in my datagrid they need to specify a client code. in order for them to arrive at a client code, i am offering them a search facility where they can search by name or department. then they can select the correct entry from a results grid. this search facility is what i have put inside the ModalPopup control.

1. when my ModalPopup control gets launched, is there any way i can pass a request to the user control within it? basically i want to set the focus within a particular textbox within the user control.

2. when my ModalPopup control gets launched, is there anyway i can pass a parameter to the user control within it then execute a codebehind method automatically. e.g. so if a user is on the grid and types in 'Sm' then clicks the popup button, i would like to launch the popup and automatically fill the search textbox with 'Sm' and also show them a list of results for 'Sm' as well automatically.

3. the ModalPopup control asks for an OK button. yet i will need to close it when a user clicks on any of the links within the search results grid. can this be done?

4. Finally, when a user selects a 'hit' within my popup user control, i would like to send some of this selected data back to my grid on the main page to fill the row. is this possible?

thanks again for any help. if you like i can send this sample in once im finished with a dummy xml dataset so that you can use it as an example. just let me know.


Hi Wee Bubba,

1-3. Take a look at this post:http://forums.asp.net/thread/1386346.aspx. Unfortunately it's not completely trivial to do some of the things you want - yet. We're working on making a lot of these scenarios easier in our next release (we don't have a date yet - but it should be within the next few weeks). Essentially the strategy boils down to: 1) Do whatever it is you want to do on the server (i.e. when the user clicks a button, setup whatever content you want in yourModalPopup, etc.), 2) usingRegisterStartupScript, send back some JavaScript to the client that shows the popup. It gets tricky with theUpdatePanel, but the code in that post should be safe to copy/paste where you need it for now.

4. If everything's wrapped inUpdatePanels, you can have a server event raised by a click in your modal popup update some data in the form (and then also close theModalPopup from the server in the same way you opened it on the server).

If any of that wasn't detailed enough, please ask about any other questions that you have.

Thanks,
Ted

Ted

I do have one more unrelated question that occurred to me yesterday evening. As I was having a few difficulties implementing the ModalPopup control (I appreciate it's still in beta) I got to thinking about alternative solutions. I thought about the following 2 alternatives:

- Using an old fashioned non-Atlas javascript child window to hold my search facility.

- Placing my search facility within a hidden <div> then swapping the layer's visibility when a user clicks the popup button. (i believe i can maintain the state of the layer's visibility by including a hidden field to keep track of this).

I then tried to understand how a ModalPopup control was any different to these traditional methods I have just outlined, what advantages it had etc. To be honest I couldn't work out the difference. I couldn't tell myself why I had been working so hard to use this control, other than my mind had been focused on Atlas at the time with using the UpdatePanel.

Can you give me any reasons why it is better to use this control? Otherwise I'm thinking of using one of the old-fashioned javascript routes as described above in order to save development time. Thanks again!


Hi WeeBubba,

ModalPopup doesn't really offer a lot more than either of your solutions in terms of functionality, although its user interface may be a little friendlier. Most of the "Atlas" Control Toolkit is not designed to be better than anything you could write in JavaScript by hand (look atConfirmButton, for example). The real benefit withModalPopup is that you don't have to re-code this scenario for every page you want to behave this way - and then tweak all of those when you realize your script doesn't run quite as expected on all the browsers you have to support.

You definitely shouldn't go crazy trying to rework things just to use one of our controls if you do it much easier in JavaScript though.

Thanks,
Ted


WeeBubba - you may want to look at the example code I placed on my blog at tech-review.org. I had spent nearly three weeks trying to get the modal to be a bit more form intensive. It is actually relatively simple to do what you are trying to do if you do not not mind incorporating a bit more code into your user control. While my code is not totally documented (I wrote the article at 3 am after a well documented article was lost due to to CS loosing my session and subsequently my article... ) it is doumented where needed and provides a framework for handling actual forms within a ModalPopUp...

No comments:

Post a Comment