hi, there, i came up with thisd login page. i came up with username , password and result textbox. i have included the C# behind code. i want to use roles and membership, but don't know how. i am not suppose to come up with any dropdownlist or textbox for that. i have also included the sql stored procedure codes. please help. its urgent. i have three roles including manager, delivery boy and customer.
<asp:TextBox ID="txtUsername" runat="server" style="z-index: 100; left: 319px; position: absolute; top: 17px" />
<asp:TextBox ID="txtPassword" TextMode="Password" runat="server" style="z-index: 101; left: 320px; position: absolute; top: 54px"></asp:TextBox>
<asp:TextBox TextMode="MultiLine" ID="txtShowResults" runat="server" style="z-index: 102; left: 182px; position: absolute; top: 169px" Height="129px" Width="363px"></asp:TextBox>
<asp:Button ID="mybutton" runat="server" OnClientClick="return LenofPassword();" Text="Submit" style="z-index: 103; left: 295px; position: absolute; top: 95px" OnClick="mybutton_Click" Width="114px" />
<asp:Label ID="Label1" runat="server" Style="z-index: 104; left: 210px; position: absolute;
top: 19px" Text="Username" Width="88px"></asp:Label>
<asp:Label ID="Label2" runat="server" Style="z-index: 105; left: 214px; position: absolute;
top: 55px" Text="Password" Width="82px"></asp:Label>
<asp:Label ID="Label3" runat="server" Style="z-index: 107; left: 324px; position: absolute;
top: 135px" Text="Result" Width="39px"></asp:Label>
[B]Behind c# code[/B]
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
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;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void mybutton_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("couriersystemconnectinstring");
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "insertmytable";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@Username", SqlDbType.VarChar));
cmd.Parameters.Add(new SqlParameter("@Password", SqlDbType.VarChar));
SqlParameter result = new SqlParameter("@Result", SqlDbType.VarChar, 50);
result.Direction = ParameterDirection.Output;
SqlParameter returnValue = new SqlParameter("returnVal", SqlDbType.Int);
returnValue.Direction = ParameterDirection.ReturnValue;
cmd.Parameters.Add(returnValue);
cmd.Parameters.Add(result);
cmd.Parameters["@Username"].Value = txtUsername.Text;
cmd.Parameters["@Password"].Value = txtPassword.Text;
cmd.Connection = conn;
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
txtShowResults.Text = result.Value.ToString() + " as number of users already existing with same user name and password is " + returnValue.Value.ToString() + Environment.NewLine;
}
}
sql stored procedure
CREATE TABLE [utable] (
[username] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[password] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[id] [int] IDENTITY (1, 1) NOT NULL ,
CONSTRAINT [PK_utable] PRIMARY KEY CLUSTERED
(
[id]
) ON [PRIMARY]
) ON [PRIMARY]
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE insertmytable
(
@Username VarChar(50),
@Password varchar(50),
@Result VarChar(50) output
)
AS
DECLARE @num int
Select @num = count(*) from utable where username = @Username and password= @Password
if(@num > 0)
BEGIN
Set @Result = 'No user created'
return @num
END
ELSE
BEGIN
INSERT INTO utable
(
[username],
[password]
)
VALUES
(
@username,
@password
)
Set @Result = 'One user created'
return 0
END
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO