Click here to Skip to main content
6,822,613 members and growing! (16,176 online)
Email Password   helpLost your password?
Web Development » Ajax and Atlas » Samples     Intermediate License: The Code Project Open License (CPOL)

Login/SignUp Screen Using AJAX ModalPopupExtender

By Pramod S Kumar

How to implement a login/signup screen using the AJAX ModalPopupExtender.
Javascript, CSS, HTML, C#1.0, C#2.0, C#3.0.NET2.0, ASP.NET, Ajax, VS2005, Dev
Revision:3 (See All)
Posted:3 Apr 2008
Views:69,947
Bookmarked:71 times
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
18 votes for this article.
Popularity: 4.22 Rating: 3.36 out of 5
3 votes, 20.0%
1
3 votes, 20.0%
2

3
2 votes, 13.3%
4
7 votes, 46.7%
5

LoginModalPopup

SignupScreen.JPG

Introduction

I want to take this opportunity to introduce a sample application which shows how to use the ModalPopupExtender for logging and signup for any ASP.NET web application. In this quick demonstration, I am going to show you how we can implement a modal dialog box using AJAX in ASP.NET. A modal dialog box (formally called a ModalPopupExtender) is extremely essential in today’s applications as it avoids redirecting to a new page just to login or signup users. A simple example is shown here illustrates how to implement the same.

Background

I was looking around to see samples of how to use the ModalPopupExtender for login and signup for my site...but I could not find any. So finally, I ended up creating this login sample application so it might be useful for everyone.

Using the Code

To start with, let's try to understand the ModalPopupExtender.

ModalPopup Description

The ModalPopupExtender allows a page to display content to the user in a "modal" manner which prevents the user from interacting with the rest of the page. The modal content can be any hierarchy of controls and is displayed above a background that can have a custom style applied to it. When displayed, only the modal content can be interacted with; clicking on the rest of the page does nothing. When the user is done interacting with the modal content, a click of an OK/Cancel control dismisses the modal content and optionally runs a custom script.

ModalPopup Properties

The control is initialized with this code. The display on the modal popup element is set to None to avoid a flicker on render. The italic properties are optional:

<ajaxToolkit:ModalPopupExtender ID="MPE" runat="server"
    TargetControlID="LinkButton1"
    PopupControlID="Panel1"
    BackgroundCssClass="modalBackground" 
    DropShadow="true" 
    OkControlID="OkButton" 
    OnOkScript="onOk()"
    CancelControlID="CancelButton" 
    PopupDragHandleControlID="Panel3" />
  • TargetControlID - The ID of the element that activates the modal popup
  • PopupControlID - The ID of the element to display as a modal popup
  • BackgroundCssClass - The CSS class to apply to the background when the modal popup is displayed
  • DropShadow - Set to True to automatically add a drop-shadow to the modal popup
  • OkControlID - The ID of the element that dismisses the modal popup
  • OnOkScript - Script to run when the modal popup is dismissed with the OkControlID
  • CancelControlID - The ID of the element that cancels the modal popup
  • OnCancelScript - Script to run when the modal popup is dismissed with the CancelControlID
  • PopupDragHandleControlID - The ID of the embedded element that contains the popup header/title which will be used as a drag handle
  • X - The X coordinate of the top/left corner of the modal popup (the popup will be centered horizontally if not specified)
  • Y - The Y coordinate of the top/left corner of the modal popup (the popup will be centered vertically if not specified)
  • RepositionMode - The setting that determines if the popup needs to be repositioned when the window is resized or scrolled

This shows how you define the ModalPopupExtender for login and signup screen buttons:

<modalpopupextender id="ModalPopupExtenderLogin" 
  runat="server" targetcontrolid="Loginlnk" 
  popupcontrolid="LoginPanel" backgroundcssclass="modalBackground" 
  dropshadow="true" okcontrolid="LoginBtn" önokscript="ok()" 
  cancelcontrolid="CancelBtn" />

<modalpopupextender id="ModalPopupExtenderSignup" runat="server" 
  targetcontrolid="Signuplnk" popupcontrolid="SignupPanel" 
  backgroundcssclass="modalBackground" dropshadow="true" 
  okcontrolid="JoinBtn" önokscript="okJoin()" 
  cancelcontrolid="CancelBtn2" />

Installation

Download the AJAX Toolkit Version 1.0.20229 from this link: http://www.codeplex.com/AtlasControlToolkit/Release/ProjectReleases.aspx?ReleaseId=11121.

Also, you need ASP.NET AJAX Extensions 1.0 for ASP.NET 2.0...you can get it from this link: http://www.asp.net/ajax/downloads/.

Once you have all those, open the sample project in VS2005, and it should work.

History

  • April 3rd 2008. Initial version published.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Pramod S Kumar


Member
Pramod has been a software developer for more than 6 years now mostly working on Ajax ASP.NET web applications.
Occupation: Software Developer (Senior)
Company: NYCEDC
Location: United States United States

Other popular Ajax and Atlas articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 20 of 20 (Total in Forum: 20) (Refresh)FirstPrevNext
GeneralMy vote of 1 Pinmembersuresh suthar2:05 25 Dec '09  
Generalpopup does not work with master page Pinmembersantoshvreddy2:15 10 Dec '09  
General[My vote of 1] I just hate it when you try to download a project and its not compiled Pinmembertbenami21:51 16 Oct '09  
GeneralMy vote of 2 PinmemberAJFK8:13 7 Jul '09  
GeneralModal in Web Content Page PinmemberMember 370337723:34 22 Mar '09  
GeneralKeeping modal dialog until server side validation is complete. PinmemberRaghu Karupakala22:22 23 Jan '09  
Questionhow can i use ajax modal popup on ascx? PinmemberMember 41572293:46 21 Dec '08  
AnswerRe: how can i use ajax modal popup on ascx? PinmemberPramod S Kumar6:56 13 Jan '09  
GeneralRe: how can i use ajax modal popup on ascx? Pinmembersandeep k2:08 27 Feb '09  
GeneralHow can i make this work on Master page PinmemberT.Ashraf5:39 20 Dec '08  
GeneralRe: How can i make this work on Master page PinmemberPramod S Kumar6:58 13 Jan '09  
Generalclearing the modalpoup Pinmembervenudreamsb4u7:29 27 Oct '08  
GeneralHow to get rid from infinte scroolbar in page behind of modalpopup when the screen resolution is changed? Pinmembers a n t o s h22:27 25 Sep '08  
GeneralWorking Example of Modal Dialog Pinmembermayurmv6:06 4 Sep '08  
GeneralModalPopup Extender does not work correctly with Opera Browser PinmemberLeMoustique13:34 28 Jul '08  
QuestionLogout via Modal popup Pinmembersaquibsa23:24 2 Jun '08  
Generalis it necessary to write script for ok button? Pinmemberketaki5101:09 26 May '08  
GeneralGreat Pinmembervvvlad6:49 6 Apr '08  
Generalcan login/signup be ssl secure, while main page is not? PinmemberThanks for all the fish5:14 4 Apr '08  
GeneralRe: can login/signup be ssl secure, while main page is not? PinmemberThanks for all the fish12:02 6 May '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads.

PermaLink | Privacy | Terms of Use
Last Updated: 3 Apr 2008
Editor: Smitha Vijayan
Copyright 2008 by Pramod S Kumar
Everything else Copyright © CodeProject, 1999-2010
Web21 | Advertise on the Code Project