1 Replies - 4531 Views - Last Post: 02 August 2011 - 11:29 AM Rate Topic: -----

#1 iggy407   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 06-January 11

asp.net C# - Login.aspx issues

Posted 01 August 2011 - 08:21 PM

The issues started when I put the loginview,AnonymousTemplate and LoggedInTemplate status in the login.aspx page. The code was working fine before then it but if you login and then went back to login.aspx the login form would still show, so i put the loginview now but in the login.aspx.cs code behind page the textboxs and labels now give me an error. Is there a way I can find the aspx controls in the code behind file with the loginview?

<%@ Page Title="" Language="C#" MasterPageFile="~/Master/MasterPage.master" AutoEventWireup="true" CodeFile="login.aspx.cs" Inherits="login" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <style type="text/css">
label {
  width:130px;    /*Or however much space you need for the formís labels*/
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:LoginView ID="LoginView1" runat="server">
    <div style="margin-left: 300px;margin-top: 100px">
<table style="border: 2px solid #000;background-color:#CCFF66;">
<th>Homezid.com Login</th></tr>
<td><label><i>*</i> Email</label><asp:TextBox ID="email" BackColor="#FFFF99"  runat="server"></asp:TextBox></td></tr>
<td><label><i>*</i> Password</label><asp:TextBox ID="password" TextMode="Password"  BackColor="#FFFF99" runat="server"></asp:TextBox><br /></td></tr>
<tr><td align="center">
    <asp:Button ID="Loginsite" runat="server" Text="Login" 
        onclick="Loginsite_Click" /></td>
    <asp:Label ID="errormessage" ForeColor="Red" runat="server" Text=""></asp:Label></td>
    <asp:HyperLink ID="HyperLink1" NavigateUrl="~/register.aspx" runat="server">Register Account</asp:HyperLink></td>
    <td><asp:HyperLink ID="HyperLink2" runat="server">Forgot Password?</asp:HyperLink></td>
        <asp:LoginStatus ID="LoginStatus1" runat="server" />



using System;
using System.Configuration;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class login : System.Web.UI.Page
    SqlConnection connect;
    SqlDataReader reader;
    SqlCommand command;
    protected void Page_Load(object sender, EventArgs e)

    protected void Loginsite_Click(object sender, EventArgs e)
        connect= new SqlConnection("Server=localhost\\SqlExpress;Database=VoteNow;" + "Integrated Security=True");
        command = new SqlCommand("SELECT email,password FROM registration WHERE [email][email protected] AND [password][email protected]",connect);
        command.Parameters.AddWithValue("@email", email.Text);
        command.Parameters.AddWithValue("@password", password.Text);
        reader = command.ExecuteReader(Commandbehavior.CloseConnection);
        if (email.Text=="" || password.Text == "")
            errormessage.Text = " Please fillout the email and/or password";
        else if (reader.Read())
            FormsAuthentication.RedirectFromLoginPage(email.Text, true);


             errormessage.Text= "Email or Password is invalid";

I am receiving an error with the email.text ,password.text , errormessage.text

Is This A Good Question/Topic? 0
  • +

Replies To: asp.net C# - Login.aspx issues

#2 tlhIn`toq   User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6534
  • View blog
  • Posts: 14,450
  • Joined: 02-June 10

Re: asp.net C# - Login.aspx issues

Posted 02 August 2011 - 11:29 AM


I'm receiving an error...

but didn't tell you what it is...

See FAQ #1

FAQ (Frequently Asked Questions - Updated July 2011

  • Q: My program doesn't work. I didn't show you any code or actually tell you the error message. How do I fix it?

  • Q: How do I get Form 'A' to make a change or talk to Form 'B'

  • Q: I'm trying to make a password/login form and...
    A: Password handling tutorial

  • Q: I'm making a client/server chat program and .....
    A:Client/server chat tutorial

  • Q: I do x and y happens which I didn't expect but I don't know how to figure out why. How do I debug and find my problem?

  • Q: I don't understand XML Serialization so I can save my information/class

  • Q:How do I get sound in my program?
    A: Adding sound to your C# application

  • Q: How do I use the serial port?
    A: Serial port communication

  • Q: How do I deploy my program / Make an installer?
    A: C# application deployment project

  • Q: How do I do compression or .zip files?

  • Q: How do I do multi-threading? Having a problem with cross-threading...

  • Q: I am making a calculator as my school homework project and ...
    A: Calculator tutorial

  • Q: I've been struggling with this for days/weeks and I can't figure it out and my professor is worthless and can't teach. Can someone here explain it to me?

  • Q: How do I save some information like preferences, settings or other data?

  • Q: I want my textbox to offer suggestions as the user types.
    A: Creating an auto-complete textbox

  • Q: I want to write a program that does x, y and z with features for A, B, and C. {Notice there is no question in this question}

  • Q: I need to code to do x... Someone tell me the code for y...

  • Q: What is the best programming language? What programming language should I learn?

  • Q: How do I get my program to programmatically simulate a mouse click or button press?
    A: Simulate mouse and keystroke (even to another application)

  • Q: I'm not really sure what I want to do with my future? Do you guys like programming? I think I kinda like math and games and computers? What should I do or study?
    A: Get experience while you find yourself

[*]Q: How do I use PInvoke and the Win32 api calls to get functions not available in .NET framework?
A: Using the Win32 API Tutorial

[*]Q: How can I have both a WinForms Windows app, and still have a Console window open?

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1