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开发者_StackOverflow中文版 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
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.
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.
There's a sample modal popup using the ajaxtoolkit on asp.net
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.
Add BehaviorID="my_cool_id"
to your modalpopup extender and add this to any server function
ScriptManager.RegisterStartupScript(Page, this.GetType(),"id","function pageLoad(){$find('my_cool_id').show();}",true);
精彩评论