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:
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:
- PxWebQuery - component for working with databases
- PxSuperGrid - component for the direct display of data in the table
- PxEdit - component for data editing, similar to the TextBox component
- PxComboBox - component for selecting data from a list, similar to the DropDownList component
- PxCheckBox - component for checking the value (Check / UnCheck value)
- PxFlyComboBox - set of the consecutively linked comboboxes, suitable for the work with structured data (for example: selection of category and subcategory)
- PxGreatRepeater - component for entering data with repeating structure, maximum number of values is limited
- PxJSDatePicker - component for the date entry, based on the JavaScript
- PxDbNavigator - the component for the work with the PxWebQuery components, row cursor movement, etc.
- PxLabel - component for data display
- PxCheckBoxList - component to view and select values from the list
- PxRadioButtonList - component for view and selection of a value from the list
- PxChart - the component for displaying and working with charts
- PxFilterView - visual component for filtering the table data contents in the PxWebQuery component
- PxUploader - component for uploading binary and text files to the server
- PxLogin - component for authorization and logging into the application
- Data loading from the Oracle, MSSQL, MySQL, FireBird, Interbase database by means of the PxWebQuery components
- Program inserting, editing or deleting of row into the database by means of the PxWebQuery component
- Loading values from the PxWebQuery component via the while cycle
- Row search in the PxWebQuery component according to the value entered and the name of the column where the search shall be carried out
- The "ReOpen" procedure of the PxWebQuery component and data re-load into the PxWebQuery component
- Validation, checking of the entered values by means of the PxWebQuery component and other visual components (PxEdit, PxComboBox, etc.)
- Events of the PxWebQuery component
- A special function GetValueFromStructKey of the PxWebQuery component
- Setting the language mutation of the Px Framework
- Finding the current version of the 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