65.9K
CodeProject is changing. Read more.
Home

Load Login Page Debug Mode. Save Time.

starIconstarIconstarIconstarIconstarIcon

5.00/5 (1 vote)

Nov 6, 2014

CPOL
viewsIcon

6296

Load login page debug mode. Save time.

As a software developer, it is important to not waste your time. Everytime you launch your app in debug mode for testing and you have to fill your user and your password, it is lost time.

LoginPage.aspx

I wrote this code in order to launch my app without login. You should place it in your Page_Load event in your Login Page code behind. The goal is to simulate the click from the login button.

Code behind in your login page: LoginPage.aspx.cs:

protected void Page_Load(object sender, EventArgs e)
{
  #if DEBUG
    userTextBox.Text = "admin";
    passTextBox.TextMode = InputMode.SingleLine;  //only if TextMode = "password"
    passTextBox.Text = "password1234";
    // more optional code you need to add if mode debug ON
    clickLogin(null, null);
  #endif

 // page load code mode debug OFF .....
}

Controls in your login page. Two textboxes (user and password) and one login button (ImageButton in my case): LoginPage.aspx:

<telerik:RadTextBox runat="server" ID="userTextBox" >
</telerik:RadTextBox>
                                         
<telerik:RadTextBox runat="server" TextMode="Password" ID="passTextBox">
</telerik:RadTextBox>
                                             
<asp:ImageButton  ImageUrl="~/images/btnLogin.gif" ID="btnLogin" runat="server"
OnClick="clickLogin" />

If this post helped you, please leave a comment.