views:

1108

answers:

4

Hey guys,

What I am trying to do is create a bit of reusable code that can write a modal popup, either through javascript or using the ajaxcontrol toolkit all from the code behind.

The modal would be a sort of login pop up for controlling access to more restricted areas of the website allowing certain users to re-credential in for higher access.

I was thinking of doing a user control but I forsee some problems with passing all of the appropriate information along without it being completely hoaky.

If anyone has any good links or advice for doing so it would be greatly appreciated!

Thanks!

EDIT: I know how to use the ajax control toolkit and its controls, and I know how to make login screens, I'm asking how to do this entirely from the code behind from a class that would be independent of its implementation

+2  A: 

Write a server control or an asp.net extender control like ajax control toolkit does.

The best you can do is download the source of AjaxControlToolkit from CodePlex and explore the source of ModalPopup within that.

this. __curious_geek
didn't think about this, will look into it
Jimmy
this is looking pretty promising, thanks a lot, I'm using the following tutorial and so far so good: http://www.asp.net/learn/Ajax-Control-Toolkit/tutorial-49-cs.aspx
Jimmy
A: 

Hey,

The modalpopupextender in the Ajax control toolkit is easy to use, plus it has a server or client side method for showing the popup (in past versions, I had trouble with the server-side method, but it may have been resolved in the current version).

You could put the modalpopupextender inside the master page, and create a JS method in the master page you can call to invoke the modal popup extender, like:

function showPopup() { var modal = $find("<%= mpe1.ClientID %>"); modal.show(); }

The contents of the popup can be replaced via javascript, as you control that content.

Brian
A: 

Another thing you can do is just simply call the popupExtender to show from the code behind file. As we know the extender has to be somehow linked to a target control, just add a dummy control as a hidden textbox (actually to hide the control, do it from the asp file, as style="display:none" not from the control properties (visible=false) otherwise it won't work), and then just call from the code behind the extender like this:

DummyTextBox_ModalPopupExtender.Show();

You can call it in the page_load or with anyother trigger.

No need javascript neither client side, just, server side. Xds.

Xds