Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Experts,

I have deployed one site before six month.
It is working fine till the date.

in this, the login page load completely at first time.
and it contain parent-child combo box controll.

So when i select one value from first combo box, it will fill second combo box.
then i can able to login in this site.

but now, my first combo filled successfully, but when i select one option from it, page can not post back and not load second combo box.

even i am not able to click login button.

How it is possible and how can i resolve this problem.

any hell will be appreciate.

thanks in advance


This is my Code

Login.aspx
ASP.NET
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="LogIn.aspx.cs" Inherits="LogIn"
    Culture="auto" meta:resourcekey="PageResource1" UICulture="auto" EnableTheming="false" %>

<%@ Register Assembly="DevExpress.Web.v10.1" Namespace="DevExpress.Web.ASPxLoadingPanel"
    TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v10.1" Namespace="DevExpress.Web.ASPxCallback"
    TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v10.1" Namespace="DevExpress.Web.ASPxEditors"
    TagPrefix="dx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head  runat="server">
    <title>Payroll :: Login</title>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <link type="text/css" rel="Stylesheet" href="../HttpCombiner.ashx?s=Set_Css_login&t=text/css&v=2.1" />
    <link rel="FAVICON ICON" type="image/gif" href="../images/Favicon.gif" />
</head>
<body>

    <script type="text/javascript" src="../HttpCombiner.ashx?s=Set_Javascript&t=type/javascript&v=2">
    </script>

    <script language="javascript" type="text/javascript">
    </script>

    <form id="form1"  runat="server" defaultbutton="btnLogin1">

    <script language="javascript" type="text/javascript">

        var prm = Sys.WebForms.PageRequestManager.getInstance();
        prm.add_initializeRequest(prm_InitializeRequest);
        prm.add_endRequest(prm_EndRequest);

        function prm_InitializeRequest(sender, args) {
            document.getElementById('CheckJScript').style.visibility = 'hidden';
            hideWaiting();

        }
        function prm_EndRequest(sender, args) {
            document.getElementById('CheckJScript').style.visibility = 'hidden';
            hideWaiting();

        }
    </script>

    <div id="divwrape"  runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <div id="waiting" style="position: absolute; left: 0px; top: 0px; background-color: white;
                    height: 100%; width: 100%;">
                    <center>
                        <table width="100%" style="padding-removed 150px;">
                            <tr id="CheckJScript"  runat="server" style="visibility: visible;">
                                <td align="center" style="color: Red;">
                                    <h4>
                                        Java Script is disable.
                                        <br />
                                        Please Enabled JavaScript and Reload Page.
                                    </h4>
                                </td>
                            </tr>
                            <tr>
                                <td align="center">
                                    <img src="../images/processing.gif" alt=" " />
                                </td>
                            </tr>
                        </table>
                    </center>
                </div>

                <script language="javascript" type="text/javascript">
                    document.getElementById('CheckJScript').style.visibility = 'hidden';
                </script>

                <dx:ASPxCallback ID="ASPxCallback1"  runat="server" ClientInstanceName="Callback">
                    <ClientSideEvents CallbackComplete="function(s, e) { LoadingPanel.Hide(); }" />
                </dx:ASPxCallback>
                <dx:ASPxLoadingPanel ID="LoadingPanel"  runat="server" ClientInstanceName="LoadingPanel"
                    Modal="True" Text="Processing...">
                </dx:ASPxLoadingPanel>
                <div class="login-main">
                    <!--Login Header Start-->
                    <div class="login-header-bg">
                        <!--Logo Space Start-->
                        <div class="login-logo-space">
                            <div class="login-logo">
                            </div>
                        </div>
                        <!--Logo Space End-->
                        <!--Login Title Start-->
                        <div class="login-title-space">
                            <div>
                                Member Login</div>
                        </div>
                        <!--Login Title End-->
                    </div>
                    <!--Login Header End-->
                    <!--login Contet Area Start -->
                    <div class="login-content">
                        <div class="login-page-center-content">
                            <div class="login-page-center">
                                <div class="login-raw">
                                    <div class="login-raw-a">
                                        <div class="login-name-space">
                                        </div>
                                        <div class="login-input-space" style="height: 15px">
                                            <asp:Label ID="lblError" runat="server" ForeColor="Red" Font-Bold="True" meta:resourcekey="lblErrorResource1"></asp:Label>
                                        </div>
                                    </div>
                                    <div class="login-raw-a">
                                        <div class="login-name-space">
                                            Company</div>
                                        <div class="login-input-space">
                                            <dx:ASPxComboBox ID="ddlCompanyName"  runat="server" Width="280px" AutoPostBack="True"
                                                 önSelectedIndexChanged="ddlCompanyName_SelectedIndexChanged" TabIndex="0" ClientInstanceName="ddlCompanyName">
                                            </dx:ASPxComboBox>
                                        </div>
                                    </div>
                                    <div class="login-raw-a">
                                        <div class="login-name-space">
                                            Branch</div>
                                        <div class="login-input-space">
                                            <dx:ASPxComboBox ID="ddlBranchName"  runat="server" Width="280px" AutoPostBack="True"
                                                 önSelectedIndexChanged="ddlBranchName_SelectedIndexChanged" TabIndex="0" ClientInstanceName="ddlBranchName">
                                            </dx:ASPxComboBox>
                                        </div>
                                    </div>
                                    <div class="login-raw-a">
                                        <div class="login-name-space">
                                            Current Year</div>
                                        <div class="login-input-space">
                                            <dx:ASPxComboBox ID="ddlCurrentYear"  runat="server" Width="280px" TabIndex="0" ClientInstanceName="ddlCurrentYear">
                                            </dx:ASPxComboBox>
                                        </div>
                                    </div>
                                    <div class="login-raw-a">
                                        <div class="login-name-space">
                                            User Name</div>
                                        <div class="login-input-space">
                                            <asp:TextBox ID="txtUserName" runat="server" Width="276px" TabIndex="0"></asp:TextBox>
                                        </div>
                                    </div>
                                    <div class="login-raw-a">
                                        <div class="login-name-space">
                                            Password</div>
                                        <div class="login-input-space">
                                            <asp:TextBox ID="txtPassword" runat="server" TextMode="Password" Width="276px" TabIndex="0"></asp:TextBox>
                                        </div>
                                    </div>
                                    <div class="login-raw-a">
                                        <div class="login-name-space">
                                            <div class="login-input-space">
                                                <asp:TextBox ID="txtTockenNumber" runat="server" AutoComplete="Off" Width="276px"
                                                    TabIndex="0" Text="a" Visible="false"></asp:TextBox>
                                            </div>
                                        </div>
                                        <div class="login-raw-a">
                                            <div class="login-name-space">
                                            </div>
                                            <div class="login-input-space">
                                                <div class="login-name-space">
                                                    <div class="login-button">
                                                        <%--<a id="btnLogin"  runat="server"  href="#"  önclick="btnLogin_Click">Login</a>--%>
                                                        <asp:Button ID="btnLogin1" runat="server" Text="Login" OnClick="btnLogin_Click" CssClass="login-button"
                                                            Visible="false" />
                                                        <asp:LinkButton ID="btnLogin" runat="server" OnClick="btnLogin_Click" ValidationGroup="save">Login</asp:LinkButton>
                                                    </div>
                                                </div>
                                                <div class="login-name-space">
                                                    <div class="login-button">
                                                        <%--<a id="btnCancel"  runat="server" href="#"  önclick="btnCancel_Click">Cancel</a>--%>
                                                        <asp:LinkButton ID="btnCancel" runat="server" OnClick="btnCancel_Click" TabIndex="0">Cancel</asp:LinkButton>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="login-page-bottom">
                                </div>
                            </div>
                        </div>
                        <!--login Contet Area End -->
                    </div>
                    <!--Footer Start-->
                    <div id="login-footer">
                        <div class="login-footer-mantra">
                        </div>
                    </div>
                    <!--Footer End-->
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    </form>

    <script language="javascript" type="text/javascript">
        function checkValidLogin(txtUserName, txtPassword, txtTockenNumber, td) {
            if (!chkComboSelectionTD(ddlBranchName.GetValue(), 'Branch.', td)) {
                ddlBranchName.Focus();
                return false;
            }
            if (!chkComboSelectionTD(ddlCurrentYear.GetValue(), 'Current Year.', td)) {
                ddlCurrentYear.Focus();
                return false;
            }
            if (!chkBlankFieldTD(txtUserName, 'User Name.', td)) {
                return false;
            }
            if (!chkBlankFieldTD(txtPassword, 'Password.', td)) {
                return false;
            }
            return true;
        }
        function txtPasswordKeyPress(tdError, event) {
            ClearTdTextNoImg(tdError);
            Check_CapsLock_Key(tdError, event);

        }
        function btnLoginClick(txtUserName, txtPassword, txtTockenNumber, td) {
            if (!checkValidLogin(txtUserName, txtPassword, txtTockenNumber, td)) {
                return false;
            }
            Callback.PerformCallback();
            LoadingPanel.Show();
            return true;
        }
        function callbcakon() { Callback.PerformCallback(); LoadingPanel.Show(); }

        setTimeout('hideWaiting()', 1000);

        function hideWaiting() {
            document.getElementById('waiting').style.visibility = 'hidden';
        }
    </script>

</body>
</html>


Login.aspx.cs
C#
using System;
using System.Data;
using PayrollClassLibrary;
using PayrollStaticClasses;
using System.Web;
using System.Web.Security;
using ASP;
public partial class LogIn : System.Web.UI.Page
{
    #region "Variables"

    BALLogIn objBALLogIn = new BALLogIn();
    protected string msUserID = "";
    protected string msUserVal = "";
    protected string msSessionCacheValue = "";
    protected string msSessionClientIPCacheValue = "";
    #endregion

    #region "Events"

    protected void Page_Load(object sender, EventArgs e)
    {
        lblError.Text = "";
        msUserID = txtUserName.Text.ToString().Trim();
        msUserVal = Context.Request.ServerVariables["REMOTE_ADDR"].ToString() + "@" + Request.Browser.Browser.ToString() + Request.UserAgent.ToString();
        msSessionCacheValue = "";
        try
        {

            if (!IsPostBack)
            {
                clearData();
                if (Session["test"] != null && Session["CurrentUser"] != null)
                {
                    HttpContext.Current.Cache.Remove("SessionTimeOut" + Session["test"].ToString());
                    HttpContext.Current.Cache.Remove(Session["CurrentUser"] + Session["test"].ToString());
                }
                try
                {
                    string RollCacheKey = "LoginValue," + Session["BranchCode"].ToString() + "," + Session["CompanyCode"].ToString() + "," + Session["RollCode"].ToString();
                    HttpContext.Current.Cache.Remove(RollCacheKey);
                }
                catch
                { }
                jScriptInit();
                Session.Abandon();

                fillddlCompany();
                fillddlBranchName(Convert.ToString(Convert.ToString(ddlCompanyName.Value)));
                if (Session["unAuthorised"] != null)
                {
                    lblError.Text = "You are not assigned any Role.";
                }

                ddlCompanyName.Focus();
            }

        }
        catch (Exception ex)
        {
            //throw ex;
        }


    }
    public bool ProcessPage()
    {

        msSessionCacheValue = ((global_asax)Context.ApplicationInstance).GetSessionCacheItem("SessionTimeOut", msUserID);
        // Test to access the cache and make sure it still exists
        if (msSessionCacheValue.ToString() == txtUserName.Text.ToString().Trim())
        {
            return false;
        }
        ((global_asax)Context.ApplicationInstance).InsertSessionCacheItem("SessionTimeOut", msUserID, msUserID);
        ((global_asax)Context.ApplicationInstance).InsertSessionCacheItem("CurrentUser", msUserID, msUserVal);
        return true;
    }
    protected void ddlCompanyName_SelectedIndexChanged(object sender, EventArgs e)
    {
        fillddlBranchName(Convert.ToString(ddlCompanyName.SelectedItem.Value));
        ddlBranchName.Focus();
    }
    public bool validLogin()
    {
        try
        {
            if (ddlCompanyName.SelectedIndex == 0)
            {
                lblError.Text = "Please Select Company.";
                return false;
            }
            if (ddlBranchName.SelectedIndex == 0)
            {
                lblError.Text = "Please Select Branch.";
                return false;
            }
            if (ddlCurrentYear.SelectedIndex == 0)
            {
                lblError.Text = "Please Select Current Year.";
                return false;
            }
            if (txtUserName.Text.Trim() == "")
            {
                lblError.Text = "Please Enter User Name.";
                return false;
            }
            if (txtPassword.Text.Trim() == "")
            {
                lblError.Text = "Please Enter Password.";
                return false;
            }
            return true;
        }
        catch (Exception ex)
        {
            return false;
        }
    }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        try
        {
            if (validLogin())
            {
                objBALLogIn.CompanyId = int.Parse(ddlCompanyName.SelectedItem.Value.ToString());
                objBALLogIn.BranchId = int.Parse(ddlBranchName.SelectedItem.Value.ToString());
                objBALLogIn.CurrentYear = Convert.ToString(ddlCurrentYear.SelectedItem.Text.ToString());
                objBALLogIn.MastName = txtUserName.Text;
                objBALLogIn.Password = txtPassword.Text;
                objBALLogIn.TicketNo = "a";
                objBALLogIn.IPAddress = Context.Request.ServerVariables["REMOTE_ADDR"].ToString();

                objBALLogIn.GetById();

                if (objBALLogIn.MastCode == 0)
                {
                    lblError.Text = "Wrong User Name, Password Or Token Number.";
                }
                else
                {
                    if (objBALLogIn.RoleId == 0)
                    {
                        lblError.Text = "You are not assigned any Role.";
                    }
                    else
                    {
                        lblError.Text = "";
                        Session["RollCode"] = objBALLogIn.RoleId;
                        Session["BranchCode"] = objBALLogIn.BranchId;
                        Session["CompanyCode"] = objBALLogIn.CompanyId;
                        Session["UserId"] = objBALLogIn.MastCode;
                        Session["UserName"] = Convert.ToString(txtUserName.Text);
                        Session["Year"] = objBALLogIn.CurrentYear;
                        Session["CurrentYear"] = Convert.ToString(ddlCurrentYear.SelectedItem.Text);
                        DataSet DS = new DataSet();
                        DataTable dt = new DataTable();
                        DS = objBALLogIn.GetCompBrInfo();
                        dt = DS.Tables[0];
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            Session["CompName"] = Convert.ToString(dt.Rows[0]["CompanyName"]);
                            Session["CompAddress"] = Convert.ToString(dt.Rows[0]["compAddress"]);
                            Session["BrName"] = Convert.ToString(dt.Rows[0]["BranchName"]);
                            Session["BrAddress"] = Convert.ToString(dt.Rows[0]["BranchAddress"]);

                            Session["SMTPIP"] = Convert.ToString(dt.Rows[0]["SMTPIP"]);
                            Session["SMTPEmail"] = Convert.ToString(dt.Rows[0]["SMTPEmail"]);
                            string uniqueSessionKey = "";
                            uniqueSessionKey = uniqueSessionKey + DateTime.Now.Millisecond.ToString();
                            uniqueSessionKey = uniqueSessionKey + DateTime.Now.Day.ToString();
                            uniqueSessionKey = uniqueSessionKey + DateTime.Now.Hour.ToString();
                            uniqueSessionKey = uniqueSessionKey + ((DateTime.Now.Second) + 100).ToString();
                            Session["uniqueSessionKey"] = uniqueSessionKey;
                        }

                        Response.Redirect("../Forms/HomePage.aspx", false);
                    }
                }

            }
        }
        catch (Exception ex)
        {
            lblError.Text = ex.Message;
        }
    }

    protected void btnCancel_Click(object sender, EventArgs e)
    {
        clearData();
    }

    protected void ddlBranchName_SelectedIndexChanged(object sender, EventArgs e)
    {
        try
        {
            fillddlCurrentYear(ddlCompanyName.SelectedItem.Value.ToString(), ddlBranchName.SelectedItem.Value.ToString());
            ddlBranchName.Focus();
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

    #endregion

    #region "My Functions"

    private void clearData()
    {
        ddlCompanyName.SelectedIndex = 0;
        ddlBranchName.SelectedIndex = 0;
        ddlCompanyName.Focus();
        txtUserName.Text = "";
        txtPassword.Text = "";
        lblError.Text = "";
        txtTockenNumber.Text = "a";
        ddlCurrentYear.Items.Clear();
        ddlCurrentYear.SelectedIndex = -1;
    }

    protected void fillddlCurrentYear(string CompanyId, string BranchId)
    {
        try
        {
            if (ddlBranchName.SelectedIndex != 0)
            {
                DataSet ds = new DataSet();
                AskInfo objComboData = new AskInfo();
                ds = objComboData.GetComboDetails("ComboFill_SPTblYearMaster", Convert.ToInt16(CompanyId), Convert.ToInt16(BranchId));
                ddlCurrentYear.DataSource = ds.Tables[0];
                ddlCurrentYear.TextField = "MastName";
                ddlCurrentYear.ValueField = "MastCode";
                ddlCurrentYear.DataBind();
                ddlCurrentYear.SelectedIndex = 0;
            }
            else
            {
                ddlCurrentYear.Items.Clear();
                ddlCurrentYear.Text = "";
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

    protected void fillddlCompany()
    {
        try
        {
            DataSet ds = new DataSet();
            AskInfo objComboData = new AskInfo();
            ds = objComboData.GetComboDetails("ComboFill_SPTblCompanyMaster", 0, 0);
            ddlCompanyName.DataSource = ds.Tables[0];
            ddlCompanyName.TextField = "MastName";
            ddlCompanyName.ValueField = "MastCode";
            ddlCompanyName.DataBind();
            ddlCompanyName.SelectedIndex = 0;
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

    protected void fillddlBranchName(string companyid)
    {
        try
        {
            if (ddlCompanyName.SelectedIndex != 0)
            {
                DataSet ds = new DataSet();
                AskInfo objComboData = new AskInfo();
                ds = objComboData.GetComboDetails("ComboFill_SPTblBranMaster", Convert.ToInt16(companyid), 0);
                ddlBranchName.DataSource = ds.Tables[0];
                ddlBranchName.TextField = "MastName";
                ddlBranchName.ValueField = "MastCode";
                ddlBranchName.DataBind();
                ddlBranchName.SelectedIndex = 0;
            }
            else
            {
                ddlBranchName.Items.Clear();
                ddlCurrentYear.Items.Clear();
                ddlBranchName.Text = "";
                ddlCurrentYear.Text = "";
            }
        }
        catch (Exception ex)
        {
            lblError.Text = ex.Message;
        }
    }
    public void jScriptInit()
    {
        txtUserName.Attributes.Add("OnKeyPress", "ClearTdTextNoImg('" + lblError.ClientID + "');");
        txtPassword.Attributes.Add("OnKeyPress", "txtPasswordKeyPress('" + lblError.ClientID + "',event);");
        txtTockenNumber.Attributes.Add("OnKeyPress", "ClearTdTextNoImg('" + lblError.ClientID + "');");
        btnLogin.Attributes.Add("OnClick", "return btnLoginClick('" + txtUserName.ClientID + "','" + txtPassword.ClientID + "','" + txtTockenNumber.ClientID + "','" + lblError.ClientID + "');");
        btnLogin1.Attributes.Add("OnClick", "return btnLoginClick('" + txtUserName.ClientID + "','" + txtPassword.ClientID + "','" + txtTockenNumber.ClientID + "','" + lblError.ClientID + "');");
    }

    #endregion

}
Posted
Updated 7-Jan-13 20:41pm
v2
Comments
Sandeep Mewara 25-Dec-12 5:53am    
What you share does not mean much for a help.
"but now, my first combo filled successfully, but when i select one option from it, page can not post back and not load second combo box. even i am not able to click login button." - You need to atleast check and share the first combobox change event call - if it's async, you might be using XMLHttpRequest and that might have some issues.
Mr. Mahesh Patel 4-Jan-13 23:24pm    
dear Sandeep, Why I have to use XMLHttpRequest if Combobox provide me inbuilt methos of Postback.

Please read my disscussion with "Joe_j" as under for know more.

Thanks
Sandeep Mewara 4-Jan-13 23:28pm    
Why I have to use XMLHttpRequest if Combobox provide me inbuilt methos of Postback.
To avoid the complete page postback and full page refresh. :)

If you are OK with it, you can go ahead and use AutoPostback and implement your feature.
Mr. Mahesh Patel 4-Jan-13 23:38pm    
No Dear, I am already using Update Panel For It
Sandeep Mewara 4-Jan-13 23:41pm    
And not a single word in the question says so! You fail to share that you are using UP which would be an important information based on the question and issue you face.

1 solution

In the combox selection changed, force a postback by changing something in the child combobox, and confirm that the parent combobox has the autopostback set and causesvalidation set to True
I once had a similar issue, dont quite remember how i fixed it.
 
Share this answer
 
Comments
Mr. Mahesh Patel 4-Jan-13 6:24am    
see dear, before some time ago, it was working fine. but i have mentioned the topic about IIS and LAN. so think about Server Setting, Content Restricted by Server. i have deployed this application before 1 year ago. but problem arries now.
in More, i can say that,
The default page of my application is Forms/Login.aspx.
I have set the default document of Forms/Login.aspx in IIS.

But when i access the site as url: myIp:myPort/Forms/Login.aspx
this form working fine. but when i access same form with url: myIp:myPort (because of Forms/Login.aspx as default document),
this page not woking.
joe_j 4-Jan-13 7:40am    
Ok, let me know if I got your question right
When you try to access the page using myIP:myPort/Forms/Login.aspx the page loads
but, when u try just myIp:myPort the page doesnt load. Is that right?

Then try this, put a default.aspx page with just a redirect code in the Page Load even. The redirect should be to your /Forms/Login.aspx.
then, in your IIS set the default page as default.aspx

If the above works, then probably there is nothing wrong with the code of the page, there is probable something wrong with the redirection of IIS.

Please let me know the outcome of this.
Mr. Mahesh Patel 4-Jan-13 23:20pm    
Yes Dear, you got right.
your suggestion of Default.aspx page, i am already using from beginning.
but With my url of : "myIP:myPort" page of login.aspx load successfully, First combo Load successfully, I can Expand it successfully. but on behalf of it, my second combo not filled.

All the same this is working with Redirection from Default.aspx to Forms/Login.aspx.

I think this is an issue about URL rewrite by IIS when I set Forms/Login.aspx as Default Document.

Thanks for your interest and your suggestion, But I dont Need Alternet Solution. I need Right Solution about it.

Please search more for me.

Thanks a lot.
joe_j 7-Jan-13 1:21am    
can you please post your code here so that it can be checked by others as well
Mr. Mahesh Patel 8-Jan-13 2:34am    
I am Submitting my code here . Please see the question Extention.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900