· 8 years ago · Jan 09, 2018, 02:18 PM
1
2
3********************
4Custom Facebook Login Form
5http://urlin.us/bza8d
6(Copy & Paste link)
7********************
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40Redirected to the login page Attempt to log in using any username and password. The page that consumes the control can use the StatusMessage property to provide this message to the end user. It may be temporarily unavailable, moved or no longer exists. You may receive SMS Notifications from Facebook and can opt out at any time.Create AccountSecurity CheckThis field is required.Can't read the words below? Try different words or an audio captcha.Please enter the words or numbers you hear.Try different words or back to text.Loading.Enter the text you see above.Why am I seeing this?Security CheckThis is a standard security test that we use to prevent spammers from creating fake accounts and spamming users. Whidbey was announced to great fanfare at the 2003 Professional Developer's Conference in Los Angeles, and offers a host of new features that simplify development and reduce the amount of code .NET developers need to write. Building a Custom Registration and Login Control . Right-click Login.aspx and select View Code. The SaveCredentials method creates a new DataSet instance (we do not need to specify the System.Data namespace in which the DataSet class resides because this namespace is automatically imported at the project level in all new Visual Basic .NET projects), reads in the current credentials file (using the DataSet's ReadXml method), and then attempts to save the credentials passed to it by RaisePostBackEvent as a new row, and if successful, saves the credentials back to the XML file using the DataSet's WriteXml method. See photos and updates from friends in News Feed. Remember that you can use the Class Name and Member Name drop-downs to easily insert the signature for events and methods for the controls in a page: Private Sub RegLogin1AuthSuccess(ByVal sender As Object, ByVal e As System.EventArgs) Handles RegLogin1.AuthSuccess If Not Request.QueryString("ReturnUrl") Is Nothing Then DoRedirect = True End If End Sub Private Sub RegLogin1AuthFailure(ByVal sender As Object, ByVal e As System.EventArgs) Handles RegLogin1.AuthFailure Label1.ForeColor = System.Drawing.Color.Red Label1.Text = RegLogin1.StatusMessage Label1.Visible = True End Sub Private Sub RegLogin1RegSuccess(ByVal sender As Object, ByVal e As System.EventArgs) Handles RegLogin1.RegSuccess Label1.ForeColor = System.Drawing.Color.Green Label1.Text = RegLogin1.StatusMessage Label1.Visible = True End Sub Private Sub RegLogin1RegFailure(ByVal sender As Object, ByVal e As System.EventArgs) Handles RegLogin1.RegFailure Label1.ForeColor = System.Drawing.Color.Red Label1.Text = RegLogin1.StatusMessage Label1.Visible = True End Sub In the case of all the events except for AuthSuccess (where we do a little extra), we set the ForeColor of the Label control to either red (for failure) or green (for success), set the Text of the label to the StatusMessage property of the RegLogin control, and set the label's Visible property to True. For our RegLogin control, we will actually just use the Render method to execute a Select Case statement, and call a separate method, depending on the outcome, to render the appropriate output (registration UI or login UI) for our control: Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter) Select Case mode Case RegLoginMode.Register DisplayRegUI(output) Case RegLoginMode.Login DisplayLoginUI(output) End Select End Sub The Select Case statement evaluates the private member variable mode, which uses an enumeration for its type, and defaults to RegLoginMode.Login: Dim mode As RegLoginMode = RegLoginMode.Login The enumeration definition (which resides within the same file, but outside the class declaration) is shown below: Public Enum RegLoginMode Register Login End Enum Once we have figured out which mode we are in, we call either DisplayRegUI or DisplayLoginUI, in each case passing the HtmlTextWriter instance, output, that is passed to the Render method. A final note on the rendering of the RegLogin control: the code used to render the registration and login UI for this control could be greatly simplified by rendering only the UI elements themselves, rather than the HTML table elements used to align the elements neatly, but that would also result in a rather unsightly control. The simpler technique, which I will demonstrate with this control, is rendering the output directly from the control. Figure 8. If either the username or password do not match, we return False, and set statusMessage to an appropriate value. Sign UpIts free and always will be.JavaScript is disabled on your browser.Please enable JavaScript on your browser or upgrade to a JavaScript-capable browser to register for Facebook.An error occurred. The Web Control Library template As thoughtful as it is of Microsoft Visual Studio to add a template control class for you, I usually end up adding one with the name I want (in my project, RegLogin) and delete the default class. The last important configuration task is protecting the credentials file, which requires two steps. We will discuss these in the next section. For this reason, you might want to render the status message directly from the control if you want to ensure that the message is always displayed. The element provides the ability to apply configuration elements to a specific file or directory specified by its path attribute. This site uses cookies for analytics, personalized content and ads. A more common use of square brackets in Visual Basic is to allow the use of member names that are the same as restricted keywords, particularly for legacy code. When you attempt to log in using a username that does not exist, you should be prompted to register, as shown in Figure 9. Using the techniques explored in this article, you can create a consistent, reusable UI for authenticating users within your applications, and one that does not require you to wait for Whidbey to arrive. First, we will add a login page to the Web Application project by right-clicking the project and selecting Add > Add Web Form, and naming the file Login.aspx. If we add the element to the Web.config file at the root of the application, the restriction(s) will apply to all files handled by ASP.NET within the application. By continuing to browse this site, you agree to this use. Then, right-click ProtectMe.aspx and select Browse With. Web Applications (ASP.NET) ASP.NET Creating Controls Creating Controls Building a Custom Registration and Login Control Building a Custom Registration and Login Control . All Rights Reserved. If you click the Register link, the page will post back, and the control will switch to register mode, as shown in Figure 10 (note that the username you entered is preserved). The good news is that this is fairly easy to do, even if you do not already know the exact method signature (method name, arguments, and return type) to use. If the postback was not the result of the "Register" link being clicked, we attempt to save the provided credentials by calling the SaveCredentials method. Handling Postbacks To handle the postbacks that our control will generate at runtime, we will need to add an Implements keyword to the class declaration referencing the IPostBackDataHandler and IPostBackEventHandler interfaces: Public Class RegLogin Inherits System.Web.UI.Control Implements IPostBackDataHandler, IPostBackEventHandler IPostBackDataHandler defines two methods, LoadPostData, and RaisePostDataChangedEvent, which are used for loading the data submitted with a postback and responding to changes in data between postbacks, respectively. with admin credentials to complete these steps) and navigate to the Web Application project for this example. Show: Inherited Protected Print Export (0) Print Share IN THIS ARTICLE . Please check your spelling and retry. Figure 12 5a02188284