Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 4737

Modify the login control from code behind

$
0
0

Hello !

 I have an web application that has a login control. We need to access this application from a wireless scanner (those scanners with touch screen - I will provide the model if needed, but this is not relevant) The resolution of the scanner is tiny 240 x 320 and the application was build to be used with a PC. Basically the user uses the scanner to update a row value by scanning a bar code (the ID of that row), but I need them to log in to know who scanned the bar code.

Because of that, I want to modify from code behind the style of the login control. The original Login page has a fancy style, and all controls are stored in a table in a panel. The scanner uses Win CE.

My goal is to make this page scaled for the scanner (to fit on the scanner display)

	Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load

        Dim BrowserType As String = Request.Browser.Platform

		' This is used for debug only
        BrowserType = "WinCE"

        If BrowserType = "WinCE" Then
            ' Modify the aspect of the form
            ChangeLoginControlFormClass()
        ElseIf BrowserType = "Unknown" Then
            ' Modify the aspect of the form
            ChangeLoginControlFormClass()
        Else
            ' Remains the same
        End If

    End Sub
	
	Private Sub ChangeLoginControlFormClass()

        ' Remove table with all controls (labels , images , logincontrol )
        Panel1.Controls.Remove(Panel1.FindControl("TBL"))

        Panel1.Width = 200

        ' Add a new Login control
        Dim MyNewLogIn As New System.Web.UI.WebControls.Login
        MyNewLogIn.ID = "LoginUser"
        MyNewLogIn.EnableViewState = False
        MyNewLogIn.Width = 200
        Panel1.Controls.Add(MyNewLogIn)

        Dim FindMyLogControl As New Login
        FindMyLogControl = DirectCast(Panel1.FindControl("LoginUser"), WebControls.Login)

        If FindMyLogControl IsNot Nothing Then

            Dim UserNameLabel As New Label
            Dim PasswordLabel As New Label
            Dim UserName As New TextBox
            Dim Password As New TextBox
            Dim RememberMe As New CheckBox

	    UserNameLabel = DirectCast(FindMyLogControl.FindControl("UserNameLabel"), Label)
            If UserNameLabel IsNot Nothing Then
                ' Change Font Size
            Else
                LBL_ERR.Text = "Label control not found"
				Exit Sub
            End If
		Else
			LBL_ERR.Text = "Login control not found"
			Exit Sub
        End If

    End Sub

In the code above, the Login control is found, but labels and textbox always return nothing.

So my first thought was "ok, let's loop through the login control to see what controls will be found !"

            For Each ctrl As Control In FindMyLogControl.Controls
                Dim ControlType As String = Nothing
                ControlType = ctrl.ToString
            Next

This is the only control that was found "System.Web.UI.WebControls.Login+LoginContainer".

Is there a way to modify the LogIn control style , from code behind ?

I don't want to use two login pages ( http://social.technet.microsoft.com/wiki/contents/articles/19740.forms-authentication-with-multiple-login-pages.aspx )

Any suggestion are welcome.


Viewing all articles
Browse latest Browse all 4737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>