This is my stored procedure :
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[Insert_BranchRegistration]
#branchname varchar(100),
#address nvarchar(200),
#phone bigint,
#email varchar(200),
#bloodgroup int,
#nobags int
as
INSERT INTO [dbo].[BranchRegistration]
([branchname]
,[address]
,[phone]
,[email]
,[bloodgroup]
,[nobags])
VALUES
(#branchname
,#address
,#phone
,#email
,#bloodgroup
,#nobags)
GO
ALTER procedure [dbo].[SP_BGTable] as SELECT [bgid] ,[name] FROM [dbo].[BGTable]
This is my asp.net html code.
<%# Page Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="BranchRegi.aspx.cs" Inherits="BloodBank.BranchRegi" %>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<div class="pagecontent">
<div class="addform">
<asp:Button ID="BtnAdd" runat="server" CssClass="button" Text="Add" />
<br />
<asp:Label ID="ErrorMessage" ForeColor="Red" class="label_inv" runat="server" ></asp:Label>
<br />
</div>
<div class="form">
<div class="border-line">
<div>
<span class="width"> <asp:Label ID="lblBranchName" class="label_inv" runat="server" Text="Branch Name"></asp:Label></span>
<span class="leftmargin">
<asp:TextBox ID="txtBranchName" class="textbox_body" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RfvBranchName" runat="server" ForeColor="Red" ErrorMessage="Please enter branch name." ControlToValidate="txtBranchName"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="rxvBranchName" runat="server"
ControlToValidate="txtBranchName" ErrorMessage="Only alphabets are allowed"
ForeColor="Red" ValidationExpression="[a-zA-Z]+"> </asp:RegularExpressionValidator></span>
</div>
<br />
<div>
<span class="width"> <asp:Label ID="lblAddress" class="label_inv" runat="server" Text="Address"></asp:Label></span>
<span style="margin-left:95px"> <asp:TextBox ID="txtAddress" Style="height: 70px" class="textbox_body" runat="server" TextMode="multiLine"></asp:TextBox>
<asp:RequiredFieldValidator ID="RfvAddress" ForeColor="Red" runat="server" ErrorMessage="Please enter Address." ControlToValidate="txtAddress"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="rxvAddress" runat="server"
ControlToValidate="txtAddress" ErrorMessage="Only alphabets are allowed"
ForeColor="Red" ValidationExpression="[a-zA-Z]+" > </asp:RegularExpressionValidator></span>
</div>
<br />
<div>
<span class="width"> <asp:Label ID="lblPhoneNumber" class="label_inv" runat="server" Text="Phone Number"></asp:Label></span>
<span class="leftmargin" style="margin-left:50px"> <asp:TextBox ID="txtPhonenumber" class="textbox_body" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RfvPhonenumber" ForeColor="Red" runat="server" ErrorMessage="Please enter phone number." ControlToValidate="txtPhonenumber"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="txtPhonenumber" ErrorMessage="Please enter valid mobile number"
ValidationExpression="[0-9]{10}"></asp:RegularExpressionValidator></span>
</div>
<br />
<div>
<span class="width"> <asp:Label ID="lblEmailID" class="label_inv" runat="server" Text="Email ID"></asp:Label></span>
<span class="leftmargin" style="margin-left:85px" ><asp:TextBox ID="txtEmailID" class="textbox_body" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvEmailID" ForeColor="Red" runat="server" ErrorMessage="Please enter email." ControlToValidate="txtEmailID"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator2"
runat="server" ErrorMessage="Please Enter Valid Email ID"
ValidationGroup="vgSubmit" ControlToValidate="txtEmailID"
CssClass="requiredFieldValidateStyle"
ForeColor="Red"
ValidationExpression="\w+([-+.']\w+)*#\w+([-.]\w+)*\.\w+([-.]\w+)*">
</asp:RegularExpressionValidator></span>
</div>
<br />
<div>
<span class="width"><asp:Label ID="lblGroup" class="label_inv" runat="server" Text="Blood Group"></asp:Label></span>
<span class="leftmargin">
<asp:DropDownList ID="ddlBlood" runat="server">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="rfvBloodGroup" ForeColor="Red" runat="server" ErrorMessage="Please enter valid group name." ControlToValidate="ddlBlood"></asp:RequiredFieldValidator>
</span>
</div>
<br />
<div>
<span class="width"> <asp:Label ID="lblNoBags" class="label_inv" runat="server" Text="No. of Bags"></asp:Label></span>
<span class="leftmargin"><asp:TextBox ID="txtNoBags" Style="margin-left: 5px" class="textbox_body" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvNoBags" ForeColor="Red" runat="server" ErrorMessage="Please enter branch name." ControlToValidate="txtNoBags"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator id="RegularExpressionValidator4"
ControlToValidate="txtNoBags"
ValidationExpression="\d+"
Display="Static"
EnableClientScript="true"
ErrorMessage="Please enter numbers only"
runat="server"/></span>
</div>
<br />
<div>
<span class="width" style="margin-left:200px" ><asp:Button ID="invSubmit" runat="server" Text="Submit" OnClick="invSubmit_Click" /></span>
<span style="margin-left:50px" > <asp:Button ID="invReset" runat="server" Text="Reset" /></span>
</div>
</div>
</div>
</div>
<link href="Content/site1.css" rel="stylesheet" />
<style>
.leftmargin
{
margin-left:60px;
}
.width
{
width:200px;
}
</style>
</asp:Content>
and server side C# code.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using BloodBank.Controllers;
using BloodBank.Models;
namespace BloodBank
{
public partial class BranchRegi : System.Web.UI.Page
{
#region VARIABLES
DataSet ds = null;
BranchRegistration objBranch;
Operation objOperation;
#endregion
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
filldrop();
ddlBlood.SelectedIndex = 0;
}
}
public void filldrop()
{
ds = SqlHelper.ExecuteDataset(Common.GetConnectionString(), CommandType.StoredProcedure, CommanName.StoredProcedures.Select_Group);
ddlBlood.DataSource = ds;
ddlBlood.DataTextField = "name";
ddlBlood.DataValueField = "bgid";
ddlBlood.DataBind();
ddlBlood.Items.Insert(0, new ListItem("Select", "0"));
}
protected void invSubmit_Click(object sender, EventArgs e)
{
objBranch = new BranchRegistration();
objOperation = new Operation();
try
{
objBranch.branchname = txtBranchName.Text.Trim();
objBranch.address = txtAddress.Text.Trim();
objBranch.phone = Int64.Parse(txtPhonenumber.Text.Trim());
objBranch.email = txtEmailID.Text.Trim();
//Response.Write(ddlBlood.SelectedValue.ToString());
objBranch.bloodgroup = int.Parse(ddlBlood.SelectedItem.Value);
objBranch.nobags = int.Parse(txtNoBags.Text.Trim());
objOperation.RegisterBranch(objBranch);
ErrorMessage.Text = CommanName.Messages.registerSuccess;
}
catch (Exception)
{
ErrorMessage.Text = CommanName.Messages.registerUnsuccess;
}
}
}
}
and
int iResult = SqlHelper.ExecuteNonQuery(Common.GetConnectionString(), CommandType.StoredProcedure,CommanName.StoredProcedures.Select_Group, new SqlParameter("#branchname", objBranch.branchname), new SqlParameter("#address", objBranch.address), new SqlParameter("#phone", objBranch.phone), new SqlParameter("#email", objBranch.email), new SqlParameter("#bloodgroup", objBranch.bloodgroup), new SqlParameter("#nobags", objBranch.nobags));
The exception is:
Procedure SP_BGTable has no parameters and arguments were supplied.
ALTER procedure [dbo].[SP_BGTable] as SELECT [bgid] ,[name] FROM [dbo].[BGTable]
This is store procedure SP_BGTable. and there is no parameters! But you try to pass parameter in code.
I think you calling the wrong procedure. Change it to Insert_BranchRegistration
Related
I would like to prevent chrome browser from auto filling the username Textbox in the account login.aspx page that I have created.
I have tried setting the Textbox's AutoCompleteMode property to "None" or to "Disabled" but still nothing.
My front end code for login:
<asp:Login ID="LoginUser" runat="server" EnableViewState="false" RenderOuterTable="false" onloggedin="LoginUser_LoggedIn">
<LayoutTemplate>
<span class="failureNotification">
<asp:Literal ID="FailureText" runat="server"></asp:Literal>
</span>
<asp:ValidationSummary ID="LoginUserValidationSummary" runat="server" CssClass="failureNotification"
ValidationGroup="LoginUserValidationGroup"/>
<div class="accountInfo">
<fieldset class="login">
<legend><asp:Literal ID="Literal3" runat="server" Text="<%$ Resources:chienvh.language, AccountInformation%>" /></legend>
<p>
<%--<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">Username:</asp:Label>--%>
<asp:TextBox ID="UserName" runat="server" CssClass="textEntry" AutoPostBack="true" Placeholder="<%$ Resources:chienvh.language, Username%>" OnTextChanged="UserName_TextChanged"></asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName" CssClass="failureNotification"
ErrorMessage="User Name is required." ToolTip="User Name is required."
ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator>
</p>
<p>
<%--<asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label>--%>
<asp:TextBox ID="Password" runat="server" CssClass="passwordEntry" TextMode="Password" Placeholder="<%$ Resources:chienvh.language, Password%>"></asp:TextBox>
<asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password"
CssClass="failureNotification" ErrorMessage="Password is required." ToolTip="Password is required."
ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator>
</p>
<p>
<asp:DropDownList runat="server" ID="DDLSite" DataSourceID="DSSite" DataValueField="SiteID" DataTextField="Site"></asp:DropDownList>
<asp:SqlDataSource runat="server" ID="DSSite" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
SelectCommand="Select 'Επίλέξτε Site...' [Site], 0 SiteID
union
Select [Site], [SiteID]
from Site
order by [Site]"></asp:SqlDataSource>
</p>
<p>
<asp:CheckBox ID="RememberMe" runat="server"/>
<asp:Label ID="RememberMeLabel" runat="server" AssociatedControlID="RememberMe" CssClass="inline">Keep me logged in</asp:Label>
</p>
</fieldset>
<p class="submitButton">
<asp:Button ID="LoginButton" runat="server" CommandName="Login" Text="Log In" ValidationGroup="LoginUserValidationGroup"/>
</p>
</div>
</LayoutTemplate>
</asp:Login>
And the back end:
protected void LoginUser_LoggedIn(object sender, EventArgs e)
{
string error = "";
string User_Name = LoginUser.UserName.ToString();
if (Common.Is_Inactive_User(User_Name, ref error) || error != "")
FormsAuthentication.SignOut();
Roles.DeleteCookie();
Session.Clear();
}
I'm trying to force the user to choose to fill either the Photo or the Video Textbox using the CustomValidator but it's not working, I've tried searching around and from previous questions a lot of people instructed to add the ValidateEmptyText="true" property, I tried adding it but it still won't fire.
I'm using other RequiredFieldValidators which are operating normally.
This is my aspx code of the two fields:
<asp:Button ID="btn1" runat="server" Text="+"/>
<asp:TextBox runat="server" PlaceHolder="Photos" ID="pics" ValidationGroup="txt1"></asp:TextBox>
<br />
<asp:Button ID="btn2" runat="server" Text="+"/>
<asp:TextBox ID="vids" runat="server" PlaceHolder="Videos" ValidationGroup="txt1"></asp:TextBox>
<asp:CustomValidator runat="server" ErrorMessage="Please enter either a photo or a picture!" OnServerValidate="ValidateBoxes" ValidationGroup="txt1" ValidateEmptyText="true"></asp:CustomValidator>
This is my c# Validation method:
public void ValidateBoxes(object sender, ServerValidateEventArgs e)
{
if (string.IsNullOrEmpty(pics.Text) && string.IsNullOrWhiteSpace(vids.Text))
e.IsValid = false;
else
e.IsValid = true;
}
EDIT : This is one of the text boxes and it's validators from the output screen shots.
<asp:TextBox ID ="city_in" PlaceHolder ="Enter city" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="city_in" ErrorMessage="Please enter the city!" ForeColor="Red"></asp:RequiredFieldValidator>
EDIT: This is the whole aspx Code:
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<h1>
Creating An Event
</h1>
<br />
<h3>
Please Provide the information below
</h3>
<asp:TextBox ID ="city_in" PlaceHolder ="Enter city" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="city_in" ErrorMessage="Please enter the city!" ForeColor="Red"></asp:RequiredFieldValidator>
<br />
<br />
<asp:TextBox ID="date" runat="server" PlaceHolder ="Enter date" TextMode="Date" ></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="date" ErrorMessage="Please enter the date!" ForeColor="Red" ></asp:RequiredFieldValidator>
<br />
<br />
<asp:TextBox ID="desc" runat="server" PlaceHolder = "Description"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="desc" ErrorMessage="Please enter the description!" ForeColor="Red"></asp:RequiredFieldValidator>
<br />
<br />
<asp:TextBox ID ="entertain" runat="server" PlaceHolder ="Entertainer"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="entertain" ErrorMessage="Please enter the entertainer!" ForeColor="Red"></asp:RequiredFieldValidator>
<br />
<br />
<asp:TextBox ID ="viewer" runat="server" PlaceHolder ="ID"></asp:TextBox>
<br />
<br />
<asp:TextBox ID ="location" runat="server" PlaceHolder ="Location"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ErrorMessage="Please enter the location!" ControlToValidate="location" ForeColor="Red"></asp:RequiredFieldValidator>
<br />
<br />
<p>
Please choose what type of Multimedia you would like to upload
</p>
<br />
<asp:Button ID="btn1" runat="server" Text="+"/>
<asp:TextBox runat="server" PlaceHolder="Photos" ID="pics" ></asp:TextBox>
<br />
<asp:Button ID="btn2" runat="server" Text="+"/>
<asp:TextBox ID="vids" runat="server" PlaceHolder="Videos"></asp:TextBox>
<asp:CustomValidator runat="server" ErrorMessage="Please enter either a photo or a picture!" OnServerValidate="ValidateBoxes" ValidateEmptyText="true"></asp:CustomValidator>
<br />
<br />
<asp:Button ID ="btn" runat="server" Text="Create Event" OnClick="create_Event" />
<asp:Button runat="server" Text="Cancel" OnClick="go_Profile"/>
Output:
This code was tested and works properly.
<body>
<form id="form1" runat="server">
<p>
Please choose what type of Multimedia you would like to upload
</p>
<br />
<asp:TextBox runat="server" PlaceHolder="Photos" ID="pics"></asp:TextBox>
<br />
<asp:TextBox ID="vids" runat="server" PlaceHolder="Videos"></asp:TextBox>
<asp:CustomValidator runat="server" ErrorMessage="Please enter either a photo or a picture!" OnServerValidate="ValidateBoxes" ValidateEmptyText="true"></asp:CustomValidator>
<br />
<br />
<asp:Button ID="btn" runat="server" Text="Create Event" />
<asp:Button runat="server" Text="Cancel" />
</form>
</body>
with this code:
public void ValidateBoxes(object sender, ServerValidateEventArgs e)
{
if (string.IsNullOrEmpty(pics.Text) && string.IsNullOrWhiteSpace(vids.Text))
e.IsValid = false;
else
e.IsValid = true;
}
if I enter any value in either of the two textboxes, the Validator is not shown.
I wanted to leave a comment but figured it would be best to display to you exactly what I tested this way you know what is working.
You have to make sure the Page IsValid before creating your event...
protected void btn_Click(object sender, EventArgs e)
{
if (IsValid)
{
Response.Write("Creating an event");
}
}
I am trying to trigger an SelectedIndexChanged from the ddlMake dropdownlist but the event is not firing, if I shift the ddlMake outside of my CreateUserWizard, it will work. Am I doing anything wrong:
<asp:CreateUserWizard runat="server" ID="RegisterUser" ViewStateMode="Disabled" OnCreatingUser="RegisterUser_CreatingUser" OnCreatedUser="RegisterUser_CreatedUser" >
<LayoutTemplate>
<asp:PlaceHolder runat="server" ID="wizardStepPlaceholder" />
<asp:PlaceHolder runat="server" ID="navigationPlaceholder" />
</LayoutTemplate>
<WizardSteps>
<asp:CreateUserWizardStep runat="server" ID="CreateUserWizardStep1">
<ContentTemplate>
<p class="message-info">
Passwords are required to be a minimum of <%: Membership.MinRequiredPasswordLength %> characters in length.
</p>
<p class="validation-summary-errors">
<asp:Literal runat="server" ID="ErrorMessage" />
</p>
<div class="row-fluid MT35">
<div class="span3">User ID:</div>
<div class="span8">
<asp:TextBox runat="server" ID="UserName" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="UserName"
CssClass="field-validation-error"
ErrorMessage="The user name field is required." Display="Dynamic" />
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" Text="Username length must be between 5 to 12 characters without spacing."
ControlToValidate="UserName" SetFocusOnError="true"
ValidationExpression="^[a-zA-Z0-9'#&#_]{5,12}$" Display="Dynamic" />
</div>
<div class="row-fluid ">
<div class="span3">Password:</div>
<div class="span8">
<asp:TextBox runat="server" ID="Password" TextMode="Password" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="Password"
CssClass="field-validation-error" ErrorMessage="The password field is required." />
</div>
<div class="row-fluid ">
<div class="span3">Confirm Password:</div>
<div class="span8">
<asp:TextBox runat="server" ID="ConfirmPassword" TextMode="Password" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="ConfirmPassword"
CssClass="field-validation-error" Display="Dynamic" ErrorMessage="The confirm password field is required." />
<asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="Password" ControlToValidate="ConfirmPassword"
CssClass="field-validation-error" Display="Dynamic" ErrorMessage="The password and confirmation password do not match." />
</div>
</div>
<div class="row-fluid MT35">
<div class="span3">Your Car:</div>
<div class="span8 YourCarInformation">
<asp:DropDownList ID="ddlCarMake" OnSelectedIndexChanged="ddlMake_SelectedIndexChanged" AutoPostBack="True" runat="server" CssClass="span12"></asp:DropDownList>
<asp:DropDownList ID="ddlCarModel" runat="server" CssClass="span12"></asp:DropDownList>
<asp:TextBox ID="txtRegistration" CssClass="pull-left" runat="server" placeholder="registration date dd/mm/yyyy"></asp:TextBox>
</div>
</div>
</div>
<div class="row-fluid">
<div class="span3">Recieve Newsletter:</div>
<div class="span8 RadioBtn">
<label class="radio">
<asp:RadioButtonList ID="rbNewsLetter" runat="server" RepeatDirection="Horizontal">
<asp:ListItem Text="Yes" Value="true" Selected="True" />
<asp:ListItem Text="No" Value="false" />
</asp:RadioButtonList>
</label>
</div>
</div>
</div>
</div>
</ContentTemplate>
<CustomNavigationTemplate />
</asp:CreateUserWizardStep>
</WizardSteps>
</asp:CreateUserWizard>
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
RegisterUser.ContinueDestinationPageUrl = Request.QueryString["ReturnUrl"];
DropDownList ddlCarMake =
(DropDownList)CreateUserWizardStep1.ContentTemplateContainer.FindControl("ddlCarMake");
DropDownList ddlCarModel =
(DropDownList)CreateUserWizardStep1.ContentTemplateContainer.FindControl("ddlCarModel");
ddlCarMake.DataSource = ds.Tables[0];
ddlCarMake.DataTextField = "CarMake";
ddlCarMake.DataValueField = "CarMake";
ddlCarMake.DataBind();
ddlCarMake.Items.Insert(0, new ListItem("Any", ""));
ddlCarMake.Items.Insert(ds.Tables[0].Rows.Count + 1, new ListItem("Others", "Others"));
ddlCarModel.Items.Insert(0, new ListItem("Any", ""));
}
}
protected void ddlMake_SelectedIndexChanged(object sender, EventArgs e)
{
VehicleBLL vehicleBll = new VehicleBLL();
DropDownList ddlCarMake = (DropDownList)CreateUserWizardStep1.ContentTemplateContainer.FindControl("ddlCarMake");
DropDownList ddlCarModel = (DropDownList)CreateUserWizardStep1.ContentTemplateContainer.FindControl("ddlCarModel");
DataSet ds = null;
if (ddlCarMake.SelectedIndex != 0)
{
ds = vehicleBll.GetCarModel(ddlCarMake.SelectedValue);
ddlCarModel.DataSource = ds.Tables[0];
ddlCarModel.DataTextField = "CarModel";
ddlCarModel.DataValueField = "CarModel";
ddlCarModel.DataBind();
ddlCarModel.Items.Insert(0, new ListItem("Any", ""));
}
}
Ok, found the answer after half a day went by, remove the ViewStateMode="Disabled" in the CreateUserWizard control and everything works fine.
i think you have to do this
first put the dropdownlist in update panel
then put the autopostback in dropdownlist property to true
that's will solve the problem
I'm working on a project thats already build and working fine.What I need to do now is to encrypt the password with salt.Normally I can do this and all, but I'm struggling to see where the control asp:Login gets the username and password.I have searched all over the project and cant find any details to where the username and password gets retrieved from the Database and where it checks if it is correct.Here are the markup:
<asp:Login ID="LoginUser" runat="server" EnableViewState="False" RenderOuterTable="False" OnLoggingIn="LoginUser_LoggingIn">
<LayoutTemplate>
<div class="accountInfo">
<fieldset class="Login">
<p>
<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName" CssClass="text"></asp:Label>
<asp:TextBox ID="UserName" runat="server" CssClass="textEntry"></asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName"
CssClass="failureNotification" ErrorMessage="User Name is required." ToolTip="User Name is required."
ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator>
</p>
<p>
<asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password" CssClass="text"></asp:Label>
<asp:TextBox ID="Password" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password"
CssClass="failureNotification" ErrorMessage="Password is required." ToolTip="Password is required."
ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator>
</p>
</fieldset>
<span class="error">
<asp:Literal ID="FailureText" runat="server"></asp:Literal>
</span>
<asp:ValidationSummary ID="LoginUserValidationSummary" runat="server" CssClass="error"
ValidationGroup="LoginUserValidationGroup" />
<p class="submitButton">
<asp:Button CssClass="submitButton" ID="LoginButton" runat="server" CommandName="Login"
ValidationGroup="LoginUserValidationGroup" Text="d" OnClick="LoginButton_Click" />
</p>
</div>
</LayoutTemplate>
</asp:Login>
and here are the code-behind:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using mycompany.BaseCode;
using System.Threading;
namespace mycompany.Account
{
public partial class Login : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
//RegisterHyperLink.NavigateUrl = "Register.aspx?ReturnUrl=" + HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"]);
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(SessionManager.Culture);
lblLoginTitle.Text = Resources.Login.LoginTitle;
lblExtraInfo.Text = Resources.Login.ExtraInfo;
var llb = (Label)LoginUser.FindControl("UserNameLabel");
llb.Text = Resources.Login.Username;
llb = (Label)LoginUser.FindControl("PasswordLabel");
llb.Text = Resources.Login.Password;
LoginUser.FailureText = Resources.Login.FailureText;
var rfv = (RequiredFieldValidator)LoginUser.FindControl("PasswordRequired");
rfv.ErrorMessage = Resources.Login.PasswordRequired;
rfv = (RequiredFieldValidator)LoginUser.FindControl("UserNameRequired");
rfv.ErrorMessage = Resources.Login.UsernameRequired;
var btn = (Button)LoginUser.FindControl("LoginButton");
btn.Text = Resources.Login.btnLogin;
}
}
}
There is no OnLoggingIn="LoginUser_LoggingIn" or OnClick="LoginButton_Click" events anywhere to be found.I even looked in the base code.The funny thing is it is working.
Any explanation or tips of where to find these hidden details will be deeply appreciated
It will use the default MembershipProvider configured in your web.config if you don't have any event handlers.
If you haven't configured a MembershipProvider, I think you need to handle at least the Login.Authenticate event.
I have JQuery Silder panel for Login | Register option. for referencing i have include demo of this slider Jquery Login | Register Slider Panel
the actually problem was how to expand programatically this slider when located Literal control have value in Login Section or Register New account section. for understanding this problem i putting my design code.
<asp:Panel ID="Panel_Login_Register" runat="server" CssClass="Panel_Slide">
<div id="toppanel">
<div id="panel">
<div class="content clearfix">
<asp:Panel ID="Panel_Welcome" runat="server" CssClass="left">
<h1>Welcome to Om Investment</h1>
<p class="grey">Om Investment Stock Market Research Trading & Advisory, the most successful market
trading team and has predicted the market direction always ahead of others, our
powerful and high volume Market Gains trading team will deliver high returns to
the Capital invested by clients, We have a consistent success ratio genuine more than
80% in every type of Market.</p>
</asp:Panel>
<asp:Panel ID="Panel_Login" runat="server" CssClass="left" Width="200px" DefaultButton="btnlogin">
<h1>Member Login</h1>
<asp:Label ID="Label2" runat="server" Text="Username:" CssClass="grey" AssociatedControlID="txtusername"></asp:Label>
<cc1:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender4" runat="server" TargetControlID="txtusername" WatermarkText="Enter username here"/>
<asp:TextBox ID="txtusername" runat="server" CssClass="field" ValidationGroup="Login"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="<span style='color:Black'><b>Required Field Missing</b><br />Username is required.</span>"
ControlToValidate="txtusername" ValidationGroup="Login" Display="None" SetFocusOnError="true"></asp:RequiredFieldValidator>
<cc1:ValidatorCalloutExtender ID="ValidatorCalloutExtender2" runat="server" TargetControlID="RequiredFieldValidator2"
Width="200px" HighlightCssClass="highlight" WarningIconImageUrl="images/1329542890_dialog-warning.png"
CloseImageUrl="images/close.gif">
</cc1:ValidatorCalloutExtender>
<asp:Label ID="Label3" runat="server" Text="Password:" CssClass="grey" AssociatedControlID="txtpassword"></asp:Label>
<cc1:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender12" runat="server" TargetControlID="txtpassword"
WatermarkText="123456789"/>
<asp:TextBox ID="txtpassword" runat="server" CssClass="field" ValidationGroup="Login" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="<span style='color:Black'><b>Required Field Missing</b><br />Password is required.</span>"
ControlToValidate="txtpassword" ValidationGroup="Login" Display="None"></asp:RequiredFieldValidator>
<cc1:ValidatorCalloutExtender ID="ValidatorCalloutExtender3" runat="server" TargetControlID="RequiredFieldValidator3"
Width="200px" HighlightCssClass="highlight" WarningIconImageUrl="images/1329542890_dialog-warning.png"
CloseImageUrl="images/close.gif">
</cc1:ValidatorCalloutExtender><br />
<asp:CheckBox ID="chk_remember" runat="server"/> <asp:Label ID="Label4" runat="server" Text="Remeber Me ?" CssClass="grey"></asp:Label>
<div class="clear"></div>
<asp:Button ID="btnlogin" runat="server" Text="Login" CssClass="bt_login" ValidationGroup="Login" OnClick="btnlogin_Click" />
<a class="lost-pwd" href="password_recover.aspx"> Lost your password ?</a>
<div class="clear"></div>
<p class="grey"><asp:Literal ID="ltr_error" runat="server"></asp:Literal></p>
</asp:Panel>
<asp:Panel ID="Panel_Register" runat="server" CssClass="left right" DefaultButton="btn_register" Width="356px">
<h1>Create New Account</h1>
<p class="grey">(All the fields are compulsory)</p>
<table><tr><td><asp:Label id="Label6" runat="server" Text="Your Name*" AssociatedControlID="txtname" CssClass="grey"></asp:Label> <cc1:TextBoxWatermarkExtender id="TextBoxWatermarkExtender5" watermarkText="Enter your name" runat="server" TargetControlID="txtname">
</cc1:TextBoxWatermarkExtender> <cc1:FilteredTextBoxExtender id="FilteredTextBoxExtender2" runat="server" TargetControlID="txtname" ValidChars=" ,." FilterType="UppercaseLetters,LowercaseLetters,Custom">
</cc1:FilteredTextBoxExtender></td></tr>
<tr><td><asp:TextBox id="txtname" runat="server" CssClass="field" ValidationGroup="SignUp" MaxLength="50"></asp:TextBox> <asp:RequiredFieldValidator id="RequiredFieldValidator5" runat="server" ValidationGroup="SignUp" SetFocusOnError="true" Display="None" ControlToValidate="txtname" ErrorMessage="<span style='color:Black'><b>Required Field Missing</b><br />Your name is required.</span>"></asp:RequiredFieldValidator> <cc1:ValidatorCalloutExtender id="ValidatorCalloutExtender4" runat="server" TargetControlID="RequiredFieldValidator5" Width="200px" CloseImageUrl="images/close.gif" WarningIconImageUrl="images/1329542890_dialog-warning.png" HighlightCssClass="highlight">
</cc1:ValidatorCalloutExtender></td></tr>
<tr><td><asp:Label id="Label7" runat="server" Text="Your Username*" AssociatedControlID="txtusername1" CssClass="grey"></asp:Label> <cc1:TextBoxWatermarkExtender id="TextBoxWatermarkExtender6" watermarkText="Enter your username" runat="server" TargetControlID="txtusername1">
</cc1:TextBoxWatermarkExtender> <cc1:FilteredTextBoxExtender id="FilteredTextBoxExtender3" runat="server" TargetControlID="txtusername" FilterType="UppercaseLetters,LowercaseLetters,Numbers,Custom">
</cc1:FilteredTextBoxExtender></td></tr>
<tr><td><asp:TextBox id="txtusername1" runat="server" CssClass="field" ValidationGroup="SignUp" MaxLength="50"></asp:TextBox><asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="txtusername1" OnServerValidate="CustomValidator1_ServerValidate" SetFocusOnError="True" ValidationGroup="SignUp" CssClass="grey" ErrorMessage="<span style='color:Gray'>Username is already exist</span>"></asp:CustomValidator></td></tr>
<tr><td><asp:RequiredFieldValidator id="RequiredFieldValidator6" runat="server" ValidationGroup="SignUp" SetFocusOnError="true" Display="None" ControlToValidate="txtusername1" ErrorMessage="<span style='color:Black'><b>Required Field Missing</b><br />Your username is required.</span>"></asp:RequiredFieldValidator> <cc1:ValidatorCalloutExtender id="ValidatorCalloutExtender7" runat="server" TargetControlID="RequiredFieldValidator6" Width="200px" CloseImageUrl="images/close.gif" WarningIconImageUrl="images/1329542890_dialog-warning.png" HighlightCssClass="highlight">
</cc1:ValidatorCalloutExtender></td></tr>
<tr><td><asp:Label id="Label9" runat="server" Text="Your Account Password*" AssociatedControlID="txtpass" CssClass="grey"></asp:Label> <cc1:FilteredTextBoxExtender id="FilteredTextBoxExtender4" runat="server" TargetControlID="txtpass" ValidChars="." FilterType="UppercaseLetters,LowercaseLetters,Numbers,Custom" InvalidChars=" ,'">
</cc1:FilteredTextBoxExtender> <cc1:TextBoxWatermarkExtender id="TextBoxWatermarkExtender7" watermarkText="1234567890" runat="server" TargetControlID="txtpass">
</cc1:TextBoxWatermarkExtender></td></tr>
<tr><td><asp:TextBox id="txtpass" runat="server" CssClass="field" ValidationGroup="SignUp" MaxLength="15" TextMode="Password"></asp:TextBox> <cc1:PasswordStrength id="PasswordStrength1" runat="server" TargetControlID="txtpass" RequiresUpperAndLowerCaseCharacters="false" MinimumSymbolCharacters="0" MinimumNumericCharacters="0" StrengthStyles="TextIndicator_TextBox1_Strength1;TextIndicator_TextBox1_Strength2;TextIndicator_TextBox1_Strength3;TextIndicator_TextBox1_Strength4;TextIndicator_TextBox1_Strength5" TextStrengthDescriptions="Very Poor;Weak;Average;Strong;Excellent" HelpStatusLabelID="TextBox1_HelpLabel" PrefixText="Strength:" PreferredPasswordLength="10" StrengthIndicatorType="Text" DisplayPosition="RightSide"></cc1:PasswordStrength> <asp:RequiredFieldValidator id="RequiredFieldValidator7" runat="server" ValidationGroup="SignUp" SetFocusOnError="true" Display="None" ControlToValidate="txtpass" ErrorMessage="<span style='color:Black'><b>Required Field Missing</b><br />Your account password is required.</span>"></asp:RequiredFieldValidator> <cc1:ValidatorCalloutExtender id="ValidatorCalloutExtender8" runat="server" TargetControlID="RequiredFieldValidator7" Width="200px" CloseImageUrl="images/close.gif" WarningIconImageUrl="images/1329542890_dialog-warning.png" HighlightCssClass="highlight">
</cc1:ValidatorCalloutExtender></td></tr>
<tr><td><asp:Label id="Label10" runat="server" Text="Confirm Password*" AssociatedControlID="txtcpass" CssClass="grey"></asp:Label><cc1:TextBoxWatermarkExtender id="TextBoxWatermarkExtender8" watermarkText="1234567890" runat="server" TargetControlID="txtcpass">
</cc1:TextBoxWatermarkExtender> <cc1:FilteredTextBoxExtender id="FilteredTextBoxExtender5" runat="server" TargetControlID="txtpass" ValidChars="." FilterType="UppercaseLetters,LowercaseLetters,Numbers,Custom" InvalidChars=" ,'">
</cc1:FilteredTextBoxExtender></td></tr>
<tr><td><asp:TextBox id="txtcpass" runat="server" CssClass="field" ValidationGroup="SignUp" MaxLength="15" TextMode="Password"></asp:TextBox> <asp:RequiredFieldValidator id="RequiredFieldValidator8" runat="server" ValidationGroup="SignUp" SetFocusOnError="true" Display="None" ControlToValidate="txtcpass" ErrorMessage="<span style='color:Black'><b>Required Field Missing</b><br />Confirm password is required.</span>"></asp:RequiredFieldValidator> <asp:CompareValidator id="CompareValidator1" runat="server" ValidationGroup="SignUp" SetFocusOnError="true" Display="None" ControlToValidate="txtcpass" ErrorMessage="<span style='color:Black'><b>Entered Field is Invalid</b><br />Your new password and confirm password doesn't mathched.</span>" ControlToCompare="txtpass"></asp:CompareValidator> <cc1:ValidatorCalloutExtender id="ValidatorCalloutExtender9" runat="server" TargetControlID="RequiredFieldValidator8" Width="200px" CloseImageUrl="images/close.gif" WarningIconImageUrl="images/1329542890_dialog-warning.png" HighlightCssClass="highlight">
</cc1:ValidatorCalloutExtender> <cc1:ValidatorCalloutExtender id="ValidatorCalloutExtender11" runat="server" TargetControlID="CompareValidator1" Width="200px" CloseImageUrl="images/close.gif" WarningIconImageUrl="images/1329542890_dialog-warning.png" HighlightCssClass="highlight">
</cc1:ValidatorCalloutExtender></td></tr>
<tr><td><asp:Label id="Label12" runat="server" Text="Your Birth Date*" AssociatedControlID="txtbdate" CssClass="grey"></asp:Label> <cc1:TextBoxWatermarkExtender id="TextBoxWatermarkExtender10" watermarkText="Enter your birthdate" runat="server" TargetControlID="txtbdate">
</cc1:TextBoxWatermarkExtender></td></tr>
<tr><td><asp:TextBox id="txtbdate" runat="server" CssClass="field" ValidationGroup="SignUp"></asp:TextBox> <asp:RequiredFieldValidator id="RequiredFieldValidator10" runat="server" ValidationGroup="SignUp" SetFocusOnError="true" Display="None" ControlToValidate="txtbdate" ErrorMessage="<span style='color:Black'><b>Required Field Missing</b><br />Your birthdate is required.</span>"></asp:RequiredFieldValidator> <asp:RegularExpressionValidator id="RegularExpressionValidator3" runat="server" ValidationGroup="SignUp" SetFocusOnError="true" Display="None" ControlToValidate="txtbdate" ErrorMessage="<span style='color:Black'><b>Entered Field is Invalid</b><br/>Birth date format should be like: DD/MM/yyyy</span>" ValidationExpression="^(((0[1-9]|[12]\d|3[01])\/(0[13578]|1[02])\/((19|[2-9]\d)\d{2}))|((0[1-9]|[12]\d|30)\/(0[13456789]|1[012])\/((19|[2-9]\d)\d{2}))|((0[1-9]|1\d|2[0-8])\/02\/((19|[2-9]\d)\d{2}))|(29\/02\/((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))$"></asp:RegularExpressionValidator> <cc1:CalendarExtender id="CalendarExtender1" runat="server" TargetControlID="txtbdate" PopupButtonID="img_cal" Format="dd/MM/yyyy">
</cc1:CalendarExtender> <cc1:MaskedEditExtender id="MaskedEditExtender5" runat="server" TargetControlID="txtbdate" ErrorTooltipEnabled="True" AcceptNegative="Left" DisplayMoney="Left" MaskType="Date" OnInvalidCssClass="MaskedEditError" OnFocusCssClass="MaskedEditFocus" MessageValidatorTip="true" Mask="99/99/9999"></cc1:MaskedEditExtender> <cc1:ValidatorCalloutExtender id="ValidatorCalloutExtender13" runat="server" TargetControlID="RequiredFieldValidator10" Width="200px" CloseImageUrl="images/close.gif" WarningIconImageUrl="images/1329542890_dialog-warning.png" HighlightCssClass="highlight">
</cc1:ValidatorCalloutExtender> <cc1:ValidatorCalloutExtender id="ValidatorCalloutExtender14" runat="server" TargetControlID="RegularExpressionValidator3" Width="200px" CloseImageUrl="images/close.gif" WarningIconImageUrl="images/1329542890_dialog-warning.png" HighlightCssClass="highlight">
</cc1:ValidatorCalloutExtender></td></tr>
<tr><td><asp:Label id="Label11" runat="server" Text="Your e-mail*" AssociatedControlID="txtemail" CssClass="grey"></asp:Label><cc1:TextBoxWatermarkExtender id="TextBoxWatermarkExtender9" watermarkText="Enter your email" runat="server" TargetControlID="txtemail">
</cc1:TextBoxWatermarkExtender></td></tr>
<tr>
<td><asp:TextBox id="txtemail" runat="server" CssClass="field" ValidationGroup="SignUp" MaxLength="50"></asp:TextBox><asp:CustomValidator ID="CustomValidator2" runat="server" ValidationGroup="SignUp" ControlToValidate="txtemail" SetFocusOnError="true" OnServerValidate="CustomValidator2_ServerValidate" CssClass="grey" ErrorMessage="<span style='color:Gray'>Email is already exist</span>"></asp:CustomValidator></td></tr>
<tr><td><asp:RequiredFieldValidator id="RequiredFieldValidator9" runat="server" ValidationGroup="SignUp" SetFocusOnError="true" Display="None" ControlToValidate="txtemail" ErrorMessage="<span style='color:Black'><b>Required Field Missing</b><br />Your email is required.</span>"></asp:RequiredFieldValidator> <asp:RegularExpressionValidator id="RegularExpressionValidator2" runat="server" ValidationGroup="SignUp" SetFocusOnError="true" Display="None" ControlToValidate="txtemail" ErrorMessage="<span style='color:Black'><b>Entered Field is Invalid</b><br/>Email format should be like: name#domain.com</span>" ValidationExpression="^[\w-\.]{1,}\#([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,6}$"></asp:RegularExpressionValidator> <cc1:ValidatorCalloutExtender id="ValidatorCalloutExtender10" runat="server" TargetControlID="RequiredFieldValidator9" Width="200px" CloseImageUrl="images/close.gif" WarningIconImageUrl="images/1329542890_dialog-warning.png" HighlightCssClass="highlight">
</cc1:ValidatorCalloutExtender> <cc1:ValidatorCalloutExtender id="ValidatorCalloutExtender12" runat="server" TargetControlID="RegularExpressionValidator2" Width="200px" CloseImageUrl="images/close.gif" WarningIconImageUrl="images/1329542890_dialog-warning.png" HighlightCssClass="highlight">
</cc1:ValidatorCalloutExtender></td></tr>
<tr><td><asp:Label id="Label13" runat="server" Text="Your Phone no*" AssociatedControlID="txtphoneno" CssClass="grey"></asp:Label> <cc1:TextBoxWatermarkExtender id="TextBoxWatermarkExtender11" watermarkText="Enter your phone no" runat="server" TargetControlID="txtphoneno">
</cc1:TextBoxWatermarkExtender> <cc1:FilteredTextBoxExtender id="FilteredTextBoxExtender6" runat="server" TargetControlID="txtphoneno" FilterType="Numbers">
</cc1:FilteredTextBoxExtender></td></tr>
<tr>
<td><asp:TextBox id="txtphoneno" runat="server" CssClass="field" ValidationGroup="SignUp" MaxLength="10"></asp:TextBox><asp:CustomValidator ID="CustomValidator3" runat="server" ValidationGroup="SignUp" ControlToValidate="txtphoneno" SetFocusOnError="true" OnServerValidate="CustomValidator3_ServerValidate" CssClass="grey" ErrorMessage="<span style='color:Gray'>Phone no is already exist</span>"></asp:CustomValidator></td>
</tr>
<tr><td><asp:RequiredFieldValidator id="RequiredFieldValidator11" runat="server" ValidationGroup="SignUp" SetFocusOnError="true" Display="None" ControlToValidate="txtphoneno" ErrorMessage="<span style='color:Black'><b>Required Field Missing</b><br />Your phone no is required.</span>"></asp:RequiredFieldValidator><asp:RegularExpressionValidator id="RegularExpressionValidator4" runat="server" ValidationGroup="SignUp" SetFocusOnError="true" Display="None" ControlToValidate="txtphoneno" ErrorMessage="<span style='color:Black'><b>Entered Field is Invalid</b><br/>Phone no format should like : 9000000098<br/> +91 Not Needed<span>" ValidationExpression="^((\\+91-?)|0)?[0-9]{10}$"></asp:RegularExpressionValidator> <cc1:ValidatorCalloutExtender id="ValidatorCalloutExtender15" runat="server" TargetControlID="RequiredFieldValidator11" Width="200px" CloseImageUrl="images/close.gif" WarningIconImageUrl="images/1329542890_dialog-warning.png" HighlightCssClass="highlight">
</cc1:ValidatorCalloutExtender> <cc1:ValidatorCalloutExtender id="ValidatorCalloutExtender16" runat="server" TargetControlID="RegularExpressionValidator4" Width="200px" CloseImageUrl="images/close.gif" WarningIconImageUrl="images/1329542890_dialog-warning.png" HighlightCssClass="highlight">
</cc1:ValidatorCalloutExtender></td></tr>
<tr><td><asp:Button ID="btn_register" runat="server" Text="Register" ValidationGroup="SignUp" CssClass="bt_register" OnClick="btn_register_Click"/></td></tr>
</table>
<div class="clear"></div>
<p class="grey"><asp:Literal ID="ltr_message2" runat="server"></asp:Literal></p>
</asp:Panel>
</div>
</div>
<div class="tab">
<ul class="login">
<li class="left"> </li>
<li>Hello Guest!</li><li class="sep">|</li><li id="toggle">
<a id="open" class="open" href="#">Log In | Register</a>
<a id="close" style="display: none;" class="close" href="#">Close Panel</a>
</li>
<li class="right"> </li>
</ul>
</div>
</div>
</asp:Panel>
this slider works fine but i have no idea to how to auto expand this panel if one of the Literal have value.
In Register New Account panel i have also custome validators also i have to found the way to expand this panel if one the three custome validator throws Error message.
For details referencing i have also include js/slide.js file content:
$(document).ready(function() {
// Expand Panel
$("#open").click(function(){
$("div#panel").slideDown("slow");
});
// Collapse Panel
$("#close").click(function(){
$("div#panel").slideUp("slow");
});
// Switch buttons from "Log In | Register" to "Close Panel" on click
$("#toggle a").click(function () {
$("#toggle a").toggle();
});
});
_____________________Updated Code_____________________
this code is about how i append my custome error to literal control
protected void btnlogin_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
using (SqlConnection conn = Util.GetConnection())
{
conn.Open();
SqlCommand cmd = new SqlCommand("sp_CheckUserAccount", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("#UserName", SqlDbType.VarChar).Value = txtusername.Text.Trim();
cmd.Parameters.Add("#pass", SqlDbType.VarChar).Value = txtpassword.Text.Trim();
cmd.Parameters.Add("#Error", SqlDbType.NVarChar, 100).Direction = ParameterDirection.Output;
SqlParameter sqlParam = cmd.Parameters.Add("#Return Value", SqlDbType.Int);
sqlParam.Direction = System.Data.ParameterDirection.ReturnValue;
cmd.ExecuteNonQuery();
int returnValue = (int)cmd.Parameters["#Return Value"].Value;
if (returnValue == 1)
{
if (chk_remember.Checked == true)
{
conn.Close();
cmd.Dispose();
conn.Open();
SqlCommand cmd1 = new SqlCommand("sp_Read_User_Type", conn);
cmd1.CommandType = CommandType.StoredProcedure;
cmd1.Parameters.Add(new SqlParameter("#Userid", SqlDbType.VarChar, 50, "Id"));
cmd1.Parameters["#Userid"].Value = txtusername.Text.Trim();
SqlDataReader reader = cmd1.ExecuteReader();
while (reader.Read())
{
if (reader["Type_name"].ToString() == "Admin")
{
Response.Cookies["UName"].Value = txtusername.Text;
Response.Cookies["PWD"].Value = txtpassword.Text;
Response.Cookies["UName"].Expires = DateTime.Now.AddMonths(2);
Response.Cookies["PWD"].Expires = DateTime.Now.AddMonths(2);
Session["username"] = reader["Id"].ToString();
Response.Redirect("~/Admin/Admin_Landing_page.aspx");
}
else
{
Response.Cookies["UName"].Value = txtusername.Text;
Response.Cookies["PWD"].Value = txtpassword.Text;
Response.Cookies["UName"].Expires = DateTime.Now.AddMonths(2);
Response.Cookies["PWD"].Expires = DateTime.Now.AddMonths(2);
Session["username"] = reader["Id"].ToString();
Response.Redirect("~/EndUser/myhome.aspx");
}
}
reader.Close();
}
else
{
Response.Cookies["UName"].Expires = DateTime.Now.AddMonths(-1);
Response.Cookies["PWD"].Expires = DateTime.Now.AddMonths(-1);
conn.Close();
cmd.Dispose();
conn.Open();
SqlCommand cmd1 = new SqlCommand("sp_Read_User_Type", conn);
cmd1.CommandType = CommandType.StoredProcedure;
cmd1.Parameters.Add(new SqlParameter("#Userid", SqlDbType.VarChar, 50, "Id"));
cmd1.Parameters["#Userid"].Value = txtusername.Text.Trim();
SqlDataReader reader = cmd1.ExecuteReader();
while (reader.Read())
{
if (reader["Type_name"].ToString() == "Admin")
{
Session["username"] = reader["Id"].ToString();
Response.Redirect("~/Admin/Admin_Landing_page.aspx");
}
else
{
Session["username"] = reader["Id"].ToString();
Response.Redirect("~/EndUser/myhome.aspx");
}
}
reader.Close();
}
}
else
{
ltr_error.Text = (string)cmd.Parameters["#Error"].Value; }
}
}
}
http://www.roorkichap.com/sliding-login-panel-built-with-jquery-asp-net-vb-net-and-sql-server-2000/
download the source code and check out
Updated version:
Literal doesn't generate any tag on page. Therefore you need to set id for tag that wrap your Literal. (or something more suitable for you)
<p id="p_error" class="grey"><asp:Literal ID="ltr_error" runat="server"></asp:Literal></p>
After that you can use js for check any text.
$(document).ready(function() {
if ($("#p_error").text() != "") //choose condition more suitable for you
$("div#panel").slideDown("slow");
});