questo è l'aspx della pagina LoginProva.aspx
codice:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="LoginProva.aspx.cs" Inherits="LoginProva" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Pagina senza titolo</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table id="Table1" runat="server">
<tr>
<td style="width: 21px; height: 21px">
</td>
<td align="center">
<asp:Label ID="lblError" runat="server" Font-Bold="True" Font-Size="10pt" ForeColor="Red"></asp:Label>
</td>
</tr>
<tr>
<td style="width: 21px">
</td>
<td valign="middle">
<table cellpadding="0" cellspacing="7" width="100%">
<tr>
<td align="right" nowrap="nowrap">
<asp:Label ID="Label1" runat="server" CssClass="label">User Name</asp:Label></td>
<td align="left">
<asp:TextBox ID="TextBox1" runat="server" CssClass="txt"></asp:TextBox>
</td>
</tr>
<tr>
<td align="right" nowrap="nowrap">
<asp:Label ID="Label2" runat="server" CssClass="label">Password</asp:Label></td>
<td align="left">
<asp:TextBox ID="TextBox2" runat="server" CssClass="txt" TextMode="Password"></asp:TextBox>
</td>
</tr>
<tr>
<td align="right" style="height: 22px">
</td>
<td align="left" style="height: 22px">
<asp:Button ID="Button1" runat="server" CssClass="btn" OnClick="Button1_Click" Text="Login" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<asp:Label ID="Label3" runat="server" Text="OK!" Visible="False"></asp:Label>
</form>
</body>
</html>
questo è il codice scritto nel relativo file cs. Pagina LoginProva.aspx.cs:
codice:
using AcliLibrary;
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.ComponentModel;
using System.Data.SqlClient;
using System.Drawing;
using System.Web.SessionState;
using System.IO;
using System.Threading;
using System.Globalization;
namespace AcliCatene
{
public partial class LoginProva : System.Web.UI.Page
{
protected DifferentFunction df;
private SqlConnection GetConnection(string connectionString)
{
SqlConnection connection = new SqlConnection(connectionString);
connection.Open();
return connection;
}
protected void Page_Load(object sender, EventArgs e)
{
Session.RemoveAll();
}
protected void Button1_Click(object sender, EventArgs e)
{
//VerifyIdentity(TextBox1.Text.Trim(), TextBox2.Text.Trim(), "");
Session["GBLConnection"] = ConfigurationSettings.AppSettings["MyConnAcliCatene"].ToString();
string strSQL = "SELECT IDUtente" +
" FROM tblUtenti " +
" WHERE(Utente= " + TextBox1.Text + ") AND (Password = " + TextBox2.Text + ")";
string ris = df.FirstResult(strSQL);
if (ris.Length > 0)
Label3.Visible = true;
}
}
}