mercredi 28 mai 2014

Session Variable - The name does not exist in current context


Vote count:

0




I keep getting the error "The name "User Name" does not exist in the current context. As you can see "UserName" is clearly defined on my code behind page and I am referencing my page. So why does it say that it does not exist?


Here is my C# -



using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;


public partial class Account_Login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{}

protected void btnLogOn_Click(object sender, EventArgs e)
{
Session["SubName"] = UserName.Text;
}
}


Here is my HTML -


Please enter your username and password.



<form action="/Account/LogOn" method="post">
<div>
<fieldset>
<legend>Account Information</legend>

<div class="editor-label">
<label for="UserName">User name</label>
</div>
<div class="editor-field">
<input id="UserName" name="UserName" type="text" value="" />

</div>

<div class="editor-label">
<label for="Password">Password</label>
</div>
<div class="editor-field">
<input id="Password" name="Password" type="password" />

</div>

<p>
<input id="btnLogOn" type="submit" value="Log On" />
</p>
</fieldset>
</div>
</form>
</div>



Stijn

5,457

asked 1 min ago






Aucun commentaire:

Enregistrer un commentaire