<% @ Control Language = "C #" AutoEventWireup = "true" Inherits = "Website.Controls.LoginBox" CodeBehind = "LoginBox.ascx.cs"%>
< asp: Panel runat = "server" ID = "panelMain" ToolTip = "Enter your email and password to access the site" >
< asp: Label runat = "server" ID = "Label1" AssociatedControlID = "txtEmail" CssClass = "req" Text = "Your email" > </ asp: Label > :
<Br />
< asp: TextBox runat = "server" ID = "txtEmail" AutoCompleteType = "Email" MaxLength = "255" > </ asp: TextBox >
< asp: RequiredFieldValidator runat = "server" ID = "RequiredFieldValidator1" ControlToValidate = "txtEmail" Display = "Dynamic" ErrorMessage = "You must enter an email." > </ asp: RequiredFieldValidator >
<Br />
<Br />
< asp: Label runat = "server" ID = "Label2" AssociatedControlID = "txtPassword" CssClass = "req" Text = "Password" > </ asp: Label > :
<Br />
< asp: TextBox runat = "server" ID = "txtPassword" TextMode = "Password" MaxLength = "255" > </ asp: TextBox >
< asp: RequiredFieldValidator runat = "server" ID = "RequiredFieldValidator2" ControlToValidate = "txtPassword" Display = "Dynamic" ErrorMessage = "You must enter a password." > </ asp: RequiredFieldValidator >
<Br />
<Br />
< asp: CheckBox ID = "chkRememberMe" runat = "server" Text = "remember me." />
<Br />
<Br />
< asp: Literal ID = "strError" runat = "server" EnableViewState = "False" > </ asp: Literal >
<Br />
< asp: Button ID = "butOk" runat = "server" Text = "Login" OnClick = "butOk_Click" />
< asp: Button ID = "butCancel" runat = "server" Text = "Cancel" CausesValidation = "false" />
</ asp: Panel >
< script type = "text / javascript" >
$ ( document ) .ready ( function ()
{
$ ( "# <% = this.panelMain.ClientID%>" ) .css ( "display" , "block" );
$ ( "# <% = this.panelMain.ClientID%>" ) .dialog
({
autoOpen: false ,
modal: true
width: 400,
height: 300,
dialogClass: "popupDialog" ,
resizable: false ,
overlay: {opacity: 0.5, background: "black" }
});
$ ( ".lbPopupLink" ) .click ( function ()
{
$ ( "# <% = this.panelMain.ClientID%>" ) .dialog ( "open" );
$ ( "# <% = this.txtEmail.ClientID%>" ) .focus ();
return false ;
});
$ ( "# <% = this.butCancel.ClientID%>" ) .click ( function ()
{
$ ( "# <% = this.panelMain.ClientID%>" ) .dialog ( "close" );
return false ;
});
});
</ script >
* This source code was highlighted with Source Code Highlighter .
// Global variables
var __passwordCloneValues;
//
// Function of the jQuery UI dialog
// Should be applied to the dialog.
//
// Arguments:
// butOkId - id of the submit button
//
$ .fn.extend ({
dialogCloseAndSubmit: function (butOkId)
{
if (! Page_IsValid)
return false ;
__passwordCloneValues = new Array ();
$ ( ": password" , $ ( this )). each ( function ()
{
__passwordCloneValues.push ($ ( this ) .val ());
});
__passwordCloneValues = __passwordCloneValues.reverse ();
var dlg = $ ( this ) .clone ();
$ ( this ) .dialog ( "destroy" ) .remove ();
dlg.css ( “display” , “none” );
$ ( "Form: first" ) .append (dlg);
$ ( ": password" , dlg) .each ( function ()
{
$ ( this ) .val (__ passwordCloneValues.pop ());
});
$ ( "#" + butOkId, dlg) .click ();
return true ;
}
});
* This source code was highlighted with Source Code Highlighter .
$ ( "# <% = this.butOk.ClientID%>" ) .click ( function ()
{
return $ ( "# <% = this.panelMain.ClientID%>" ) .dialogCloseAndSubmit ($ ( this ) .attr ( "id" ));
});
* This source code was highlighted with Source Code Highlighter .
Source: https://habr.com/ru/post/40221/
All Articles