I have codes that are written and working fine as a Web Application with Codebehind file. However, I don't have the chance to convert my files to Web Application because customer wants the actual project as MVC so converting files is not enough to run the project. If I don't convert to application, it keeps given the error for my "txtUsername" and "txtPassword" does not exist in the current context.
I just need the modification to be done to make it work as in MVC logic.
under Views/login.aspx:
<%@ Page Language="C#" AutoEventWireup="True" Inherits="login" Codebehind="/Controllers/login.cs" %>
under Controllers/login.cs:
using System;
using System.Web.Security;
using System.Web.UI;
public partial class login : Page
{
protected void btnLogin_Click(object sender, EventArgs e)
{
if (Membership.ValidateUser(txtUsername.Text, txtPassword.Text))
{
FormsAuthentication.RedirectFromLoginPage(txtUsername.Text, false);
}
}
}
Even if I change my login.cs to have using System.Web.Mvc
and public partial class login: ViewPage
. It still gives me the error as "txtUsername" and "txtPassword" does not exist in the current context. I have many Web forms like this but it will be really helpful if somebody can help on how to change/move this login.aspx and login.cs from Web Forms approach to MVC approach and make them work fine without warning.