login new in telerik

    <div class="container" style="margin-top: 165px;">
        <div class="row">
            <div class="col-md-12">
                <div class="comment-box2">
                    <img alt="" src="<%#ResolveUrl("~")%>/DolnaWebsite/images/og.gif" />
                    <div class="comment-content">
                        <h2 class="h2s">Login

                            <span style="float: right;" class="st_sharethis" st_processed="yes">
                                <span style="text-decoration: none; color: rgb(0, 0, 0); display: inline-block; cursor: pointer; padding-left: 0px; padding-right: 0px; width: 16px;" class="stButton">
                                    <span class="chicklets sharethis">&nbsp;</span>
                                </span>
                            </span>

                        </h2>


                        <hr style="margin-top: 5px; margin-bottom: 5px; border: 0; border-top: 1px solid #000000;" />
                        <p></p>

                    </div>
                </div>

            </div>
        </div>
    </div>

     <asp:UpdateProgress ID="updateProgress" runat="server" AssociatedUpdatePanelID="updpnl">
        <ProgressTemplate>
            <div style="position: fixed; text-align: center; height: 100%; width: 100%; top: 0; right: 0; left: 0; z-index: 9999999; background-color: #000000; opacity: 0.7;">
                <asp:Image ID="imgUpdateProgress" runat="server" ImageUrl="~/common/images/Icons/loading.gif" AlternateText="Loading ..." ToolTip="Loading ..." Style="padding: 10px; position: fixed; top: 45%; left: 50%;" />
            </div>
        </ProgressTemplate>
    </asp:UpdateProgress>
        <asp:UpdatePanel ID="updpnl" runat="server">
                     <Triggers>
                     <asp:ASyncPostBackTrigger ControlID="ChkRememberme" />
                   </Triggers>  
        <ContentTemplate>
    <div class="login-main" style="margin-top:-20px;">
        <div class="login">
            <div class="social">
                <h4 style="margin-top:0px"><b>LOGIN</b></h4>
                <!--<ul>
  <li><a class="face" href="#">Join with Facebook</a></li>
  <li class="last-mar"><a class="twit" href="#">Join with Twitter</a></li>
  </ul>-->
            </div>
            <div class="row" style="padding-top:5px">
             <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ValidationGroup="Registra" Style=""  ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ControlToValidate="txtUsername" ErrorMessage=" Invalid Email Format " ForeColor="Red"></asp:RegularExpressionValidator>
            </div>
            <div>
            <asp:TextBox ID="txtUsername" runat="server" class="email" placeholder="User Name"   ></asp:TextBox>
                </div>
           
            <%--  <input type="text" class="email" value="User Name" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'User Name';}">--%>
            <asp:TextBox ID="txtPassword" placeholder="Password" runat="server" TextMode="Password" ></asp:TextBox>
            <%-- <input type="password" value="Password" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Password';}">--%>
         
                <ul class="button" style="padding: 0em 0em 0em 1em; margin:0;">
                    <li style="font-size:11px">
                        <asp:Button ID="btnSignin" OnClick="btnSignin_Click" runat="server" Text="Log In" />
                        <%-- <input type="submit" value="Submit" >--%>

                    </li>
                    <li style="font-size:11px">
                        <asp:Button ID="btnRegister"  ValidationGroup="Registra" runat="server"  Text="Register" OnClick="btnRegister_Click" />

                    </li>
                </ul>
             <div class="row" style="padding-right: 6.5em;">
                  <asp:CheckBox ID="ChkRememberme" runat="server"  class="checkbox" Text="Keep me Logged in" />
             </div>
            <div class="forgot">
              <%--  <label class="checkbox" style="">--%>
                 
                   <%-- <input type="checkbox"  name="checkbox" checked>--%><%--<i > </i>Keep me signed in</label>--%>
                <div class="forgot-para" style="padding-right:14px">
                    <a href="<%#ResolveUrl("~")%>/PublicWebsites/ForgotPassword.aspx">
                        <p style="text-align:left; padding-left:13px; color:#333 !important ">Forgot Your Password?</p>
                    </a>
                </div>
                <div class="clear"></div>
            </div>
        </div>
         <div class="row">
                 <%--<asp:RegularExpressionValidator ID="EMailVAlidation" runat="server" ValidationGroup="Registra"  ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ControlToValidate="txtUsername" ErrorMessage="* Invalid Email Format *" ForeColor="Red"></asp:RegularExpressionValidator>--%>
             </div>
        <div class="login-password">
                <telerik:RadLabel ID="lblshowmessage" runat="server" Text="Incorrect login or Password" Visible="false" style="color:white;"></telerik:RadLabel>
          <%-- <asp:Label ID="lblshowmessage" runat="server" Text="Incorrect login or Password"></asp:Label> --%>
         
            <%--<p>Incorrect <a href="<%#ResolveUrl("~")%>/DolnaWebsite/Default.aspx">login</a> or <a href="<%#ResolveUrl("~")%>/DolnaWebsite/ForgotPassword.aspx">Password</a></p--%>
        </div>
    </div>
         
           
            </ContentTemplate>
           
             </asp:UpdatePanel>










==============================

using BusinessEntities;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Net.Http;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace KenCommerceWeb.PublicWebsites
{
    public partial class Login : System.Web.UI.Page
    {
        List<Master_Login_User> userList = null;
        HttpClient client = new HttpClient();
        HttpResponseMessage hrm = null;

        public List<User_Personal_Information> UserPersonalInformationList = new List<User_Personal_Information>();
        public List<User_Banking_Information> UserBankingInformationList = new List<User_Banking_Information>();
        public List<User_Additional_Information> UserAdditionalInformationlist = new List<User_Additional_Information>();

        int itemdetid;
        decimal price;
        int qty;

        protected void Page_Load(object sender, EventArgs e)
        {
            var appsurl = ConfigurationManager.AppSettings["APIPath"].ToString();
            client.BaseAddress = new Uri(appsurl);

            txtUsername.Attributes.Add("onkeypress", "Alphabet()");
            if (!Page.IsPostBack)
            {
                if (Request.Cookies["UserName"] != null && Request.Cookies["Password"] != null)
                {
                    txtUsername.Text = Request.Cookies["UserName"].Value;
                    txtPassword.Attributes["value"] = Request.Cookies["Password"].Value;
                }
                lblshowmessage.Visible = false;
             
            }
            else
            {
                CheckDetails();
                //if (GetUser() == "Admin")
                //    Response.Redirect("~/Admin/AdminPage.aspx");
                //else
                //    Response.Redirect("~/Admin/Default.aspx");
            }
        }

        private void ChkRememberme_Function()
        {
            #region -- Implemanting Rememberme Functionality --

            try
            {
                //string UserName = string.Empty;

               // string Password = string.Empty;

                // Storing the User name and Password

                //if (txtUsername.Text != "")
                //{
                //    UserName = txtUsername.Text.Trim();
                //}

                //if (txtPassword.Text != "")
                //{
                //    Password = txtPassword.Text.Trim();
                //}

                // Storing it in the Cookies

                if (ChkRememberme.Checked == true)
                {
                    Response.Cookies["UserName"].Value = txtUsername.Text;
                    Response.Cookies["Password"].Value = txtPassword.Text;
                    Response.Cookies["UserName"].Expires = DateTime.Now.AddYears(50);
                    Response.Cookies["Password"].Expires = DateTime.Now.AddYears(50);
                }

                else
                {
                    Response.Cookies["UserName"].Expires = DateTime.Now.AddDays(-1);
                    Response.Cookies["Password"].Expires = DateTime.Now.AddDays(-1);

                }

                //Response.Cookies["UserName"].Value = UserName;
                //Response.Cookies["Password"].Value = Password;

            }

            catch (ArgumentNullException Exc)
            {
                //lblshowmessage.Text = "Application Error : " + Exc.Message;
            }

            #endregion
        }

        #region Check User
        private string GetUser()
        {
            if (txtUsername.Text == "Saurendra" && txtPassword.Text == "Admin@12345")
            {
                Session["Loginuserid"] = 0;
                Session["UserName"] = "Super Admin";
                Session["UserType"] = "Admin";
                return "Admin";
            }
            HttpResponseMessage hrm = client.GetAsync("api/User").Result;
            if (hrm.IsSuccessStatusCode)
            {
                userList = GetLogin_User().ToList().Where(a => a.Login_EmailId == txtUsername.Text && a.Login_Password == txtPassword.Text &&  a.Login_User_Type != "Admin" && a.IsActive == true && a.IsDelete == false).ToList();
                if (userList.Count > 0)
                {
                    Session["Loginuserid"] = userList.ToList()[0].Login_User_ID.ToString();
                    Session["UserName"] = userList.ToList()[0].Login_Username.ToString();
                    Session["UserType"] = userList.ToList()[0].Login_User_Type.ToString();
                    Session["UserMailId"] = userList.ToList()[0].Login_EmailId.ToString();
                    //Session["Loged"] = "true";
                    return userList.ToList()[0].Login_User_Type.ToString();
                }
                else
                {
                    userList = GetLogin_User().ToList().Where(a => a.Login_EmailId == txtUsername.Text && a.Login_Password == txtPassword.Text &&  a.Login_User_Type != "Admin" && a.IsActive == false && a.IsDelete == false).ToList();
                    if (userList.Count > 0)
                    {
                        Session["Loginuserid"] = userList.ToList()[0].Login_User_ID.ToString();
                        Session["txtUsername"] = txtUsername.Text;
                        Session["txtPassword"] = txtPassword.Text;
                        //Response.Redirect("~/RegistationPage.aspx");
                        return string.Empty;
                    }
                    else
                    {
                        lblshowmessage.Visible = true;
                        txtUsername.Text = "";
                        txtPassword.Text = "";
                        //  Response.Redirect("~/Login.aspx");
                        return string.Empty;
                    }
                }

            }
            else
            {
                lblshowmessage.Visible = true;
                return string.Empty;
            }
        }
        private List<Master_Login_User> GetLogin_User()
        {
            HttpResponseMessage Login_User = client.GetAsync("api/User").Result;
            if (Login_User.IsSuccessStatusCode)
            {
                userList = Login_User.Content.ReadAsAsync<List<Master_Login_User>>().Result;
                return userList.ToList();
            }
            else
            {
                return null;
            }
        }
        #endregion

        protected void btnSignin_Click(object sender, EventArgs e)
        {
     
            ChkRememberme_Function();
            if (Session["SessonforTrackOrder"] != "TrackOrder")
            {
                #region NormalLogin
                if (GetUser() != string.Empty)
                {
                    switch (GetUser())
                    {
                        case "Admin":
                            if (Convert.ToString(Request.QueryString["AucUser"]) == "1")
                            {
                                Response.Redirect("~/PublicWebsites/AuctionUserPage.aspx");
                            }
                            else if (Session["BUY NOW"] != null && Session["BUY NOW"].ToString() == "BUY NOW")
                            {
                                Response.Redirect("~/PublicWebsites/Add2Cart.aspx");
                            }
                            else if (Session["PLACE ORDER"] != null && Session["PLACE ORDER"].ToString() == "PLACE ORDER")
                            {
                                Response.Redirect("~/Order/AddCartList.aspx");
                            }
                            else
                            {
                                Response.Redirect("~/Admin/AdminPage.aspx");
                            }
                            break;
                        case "Supplier":
                        case "Gallerist":
                        case "Artist":
                        case "Seller":
                            if (Convert.ToString(Request.QueryString["AucUser"]) == "1")
                            {
                                Response.Redirect("~/PublicWebsites/AuctionUserPage.aspx");
                            }
                            else if (Session["BUY NOW"] != null && Session["BUY NOW"].ToString() == "BUY NOW")
                            {
                                Response.Redirect("~/PublicWebsites/Add2Cart.aspx");
                            }
                            else if (Session["PLACE ORDER"] != null && Session["PLACE ORDER"].ToString() == "PLACE ORDER")
                            {
                                Response.Redirect("~/Order/AddCartList.aspx");
                            }
                            else
                            {
                                Response.Redirect("~/Supplier/Default.aspx");
                            }
                            break;
                        case "Customer":
                            if (Convert.ToString(Request.QueryString["AucUser"]) == "1")
                            {
                                Response.Redirect("~/PublicWebsites/AuctionUserPage.aspx");
                            }
                            else if (Session["BUY NOW"] != null && Session["BUY NOW"].ToString() == "BUY NOW")
                            {
                                Response.Redirect("~/PublicWebsites/Add2Cart.aspx");
                            }
                            else if (Session["PLACE ORDER"] != null && Session["PLACE ORDER"].ToString() == "PLACE ORDER")
                            {
                                Response.Redirect("~/Order/AddCartList.aspx");
                            }
                            else
                            {
                                Response.Redirect("~/PublicWebsites/Default.aspx");
                            }
                            //Response.Redirect("~/PublicWebsites/Default.aspx");
                            break;
                        default:
                            Response.Redirect("~/Admin/AdminPage.aspx");
                            break;
                    }
                }
                else
                {
                  //  Response.Redirect("~/PublicWebsites/Login.aspx");
                }
                #endregion
            }
            else
            {
                #region for Track Order
                switch (GetUser())
                {
                    case "Admin":
                        if (Session["Loginuserid"] != null)
                        {
                            Response.Redirect("~/Order/OrderHistory.aspx?Loguser_Id=" + Session["Loginuserid"].ToString(), false);
                        }
                        else
                        {

                        }
                        break;
                    case "Supplier":
                    case "Gallerist":
                    case "Artist":
                    case "Seller":
                        if (Session["Loginuserid"] != null)
                        {
                            Response.Redirect("~/Order/OrderHistory.aspx?Loguser_Id=" + Session["Loginuserid"].ToString(), false);
                        }
                        else
                        {

                        }
                        break;
                    case "Customer":
                        if (Session["Loginuserid"] != null)
                        {
                            Response.Redirect("~/Order/OrderHistory.aspx?Loguser_Id=" + Session["Loginuserid"].ToString(), false);
                        }
                        else
                        {

                        }
                        break;
                    default:
                        break;
                }
                #endregion
             
            }
        }

        protected void btnRegister_Click(object sender, EventArgs e)
        {
            /*if (Session["ADD TO CART"] != null && Session["ADD TO CART"].ToString() == "ADD TO CART")
            {
                itemdetid = Convert.ToInt32(Session["itemDetID"]);
                price = Convert.ToDecimal(Session["lblRuppess"]);
                qty = Convert.ToInt32(Session["lblQty"]);
                Response.Redirect("~/PublicWebsites/Registerpage.aspx", false);
            }
            else if (Session["ADD TO WISHLIST"] != null && Session["ADD TO WISHLIST"].ToString() == "ADD TO WISHLIST")
            {
                itemdetid = Convert.ToInt32(Session["itemDetID"]);
                price = Convert.ToDecimal(Session["lblRuppess"]);
                qty = Convert.ToInt32(Session["lblQty"]);
                Response.Redirect("~/PublicWebsites/Registerpage.aspx", false);
            }
            if (Session["BUY NOW"] != null && Session["BUY NOW"].ToString() == "BUY NOW")
            {
                itemdetid = Convert.ToInt32(Session["itemDetID"]);
                price = Convert.ToDecimal(Session["lblRuppess"]);
                qty = Convert.ToInt32(Session["lblQty"]);
                Response.Redirect("~/PublicWebsites/Registerpage.aspx", false);
            }
            else if (Session["PLACE ORDER"] != null && Session["PLACE ORDER"].ToString() == "PLACE ORDER")
            {
                Response.Redirect("~/PublicWebsites/Registerpage.aspx", false);
            }
            else
            {
                Response.Redirect("~/PublicWebsites/Registerpage.aspx",false);
            }*/
         
            Response.Redirect("~/PublicWebsites/Registerpage.aspx", false);
        }


        private void CheckDetails()
        {
            #region...User Personal Information...
            HttpResponseMessage Login_User = client.GetAsync("api/UserPersonalInformation").Result;
            if (Login_User.IsSuccessStatusCode)
            {
                UserPersonalInformationList = Login_User.Content.ReadAsAsync<List<User_Personal_Information>>().Result;
                var result = (from a in UserPersonalInformationList
                              where a.Login_User_ID == Convert.ToInt32(Session["Loginuserid"])
                              select new
                              {
                                  a.User_Personal_Information_ID
                              }).ToList();
                if (result.ToList().Count() > 0)
                {
                    Session["Personal Information"] = "ok";
                }
                else
                {
                    Session["Personal Information"] = "Not ok";
                }


            }


            #endregion

            #region...Bank Information...

            HttpResponseMessage Login_Users = client.GetAsync("api/UserBankingInformation").Result;
            if (Login_Users.IsSuccessStatusCode)
            {
                UserBankingInformationList = Login_Users.Content.ReadAsAsync<List<User_Banking_Information>>().Result;
                var res = (from a in UserBankingInformationList
                           where a.Login_User_ID == Convert.ToInt32(Session["Loginuserid"])
                           select new
                           {
                               a.User_Banking_Information_ID
                           }).ToList();
                if (res.ToList().Count() > 0)
                {
                    Session["Bank Details"] = "Ok";
                }
                else
                {
                    Session["Bank Details"] = "Not Ok";
                }
            }
            else
            {
                Session["Bank Details"] = "Not Ok";
            }


            #endregion

            #region...Additional Information...
            HttpResponseMessage Login_User1 = client.GetAsync("api/UserAdditionalInformation").Result;
            if (Login_User1.IsSuccessStatusCode)
            {
                UserAdditionalInformationlist = Login_User1.Content.ReadAsAsync<List<User_Additional_Information>>().Result;
                var data = (from a in UserAdditionalInformationlist
                            where a.Login_User_ID == Convert.ToInt32(Session["Loginuserid"])
                            select new
                            {
                                a.User_Additional_Information_ID
                            }).ToList();
                if (data.ToList().Count() > 0)
                {
                    Session["Additional Information"] = "OK";
                }
                else
                {
                    Session["Additional Information"] = "Not OK";
                }
            }
            else
            {
                Session["Additional Information"] = "Not OK";
            }
            #endregion

        }
    }
}

Comments

Popular posts from this blog

Create Schema Using C# Asp .Net Dynamically.

FAQ BIND

resgination mail