Sk   En  
 
 
 
 
 
 
 
 

Components of Px Framework:


PxLogin - component for authorization and logging into the application



The PxLogin component is used for authentication and logging into the application. The component consists of two TextBox into which you enter the user name and password, and the button for confirmation and login to the application as it is shown in the picture below:

Image components PxLogin


We create a Login.aspx file and the following definition of the PxLogin component into it:

Login.aspx file:

<Prx:PxLogin ID="lgLogin" LoginFormName="Login.aspx" FirstFormAfterLogin="Adresar.aspx" runat="server" />


As it is seen from the definition of the PxLogin component two properties are defined at the same time with its definition. These properties are LoginFormName and FirstFormAfterLogin. We put the PxLogin component into everyone form, and after we have done it, the PxLogin component will make the guard and see if we are logged into the system. If you we are not logged in, the component PxLogin redirects us from the original form that is specified in the property LoginFormName, in this case it is the Login.aspx form. If we are logged in, the PxLogin component can determine it from its structure and we remain in its original form.

After we have entered name and password into each TextBox we confirm it with the button "Login" and the PxLogin component calls event "ValidateLogin". We assign the procedure where the event will be processed to this event of the PxLogin component in the body Page_Load method.

Login.aspx.cs file:

protected void Page_Load(object sender, EventArgs e)
{
   ...
   lgLogin.ValidateLogin += new ValidateLoginEventHandler(lgLogin_ValidateLogin);
   ...
}


The method lgLogin_ValidateLogin contains the input parameters, i.e. the name and the password that was entered in the form of the PxLogin component. Besides these input parameters it includes output parameters and they are AcceptLogin and ErrorMsg.

Briefly, all authorization runs in the method lgLogin_ValidateLogin and if the username and password is correct, we write true into the parameter AcceptLogin. If it is not correct we write false. In case we have entered false we also write an error message into the ErrorMsg parameter.
In case the name and password are correct and comply with the authorization and we have entered true into the AcceptLogin parameter, the PxLogin component automatically redirects us to a form which name is entered in the FirstFormAfterLogin property.

In this case it is the Adresar.aspx form. See the example below:

void lgLogin_ValidateLogin(object sender, EventArgs e, string LoginName, string Passwd,
                        ref bool AcceptLogin, ref string ErrorMsg)
{
   string GroupUsers = String.Empty;
   Int32 IdUser = -1;
   AcceptLogin = IsValidLogin(LoginName, Passwd, ref GroupUsers, ref IdUser);
   if (AcceptLogin == true)
   {
      lgLogin.GroupUsers = GroupUsers;
      lgLogin.IDUser = IdUser.ToString();
      Session["GroupUsers"] = GroupUsers.RemoveDiacritics();
   }
   else
   {
      ErrorMsg = "Nezadali ste správne meno alebo heslo !!!";
      lgLogin.GroupUsers = String.Empty;
      lgLogin.IDUser = "-1";
      Session["GroupUsers"] = null;
   }
}





Others articles of Px Framework:



It doesn't the intention of this part website, describe in detail the work with PxFramework components, a detailed description of the component available in manual, which can be downloaded here: Download manual of Px Framework

 
  PxWebQuery
  PxSuperGrid
  PxEdit
  PxComboBox
  PxCheckBox
  PxJSDatePicker
  PxDbNavigator
  PxLabel
  PxFlyComboBox
  PxGreatRepeater
  PxChart
  PxUploader
  PxFilterView
  PxCheckBoxList
  PxRadioButtonList
  PxLogin
 
 
  AddParamKey()
  AddParamWebQuery()
  AddParamGreatWeb...
  AddParamCheck()
  AddParamFlyCombo...
  AddParamCheckList()
  AddParamRadioList()
  AddParamValidation()
 
 
  AddParamFilter()