locked
Tab click is not functioning properly. RRS feed

  • Question

  • User-1506965535 posted

    Hi,

    I have 3 tabs. Where I i have given the usertype to differentiate them

    For NGO usertype is 0,1

    from NGO usertype is 2

    Please find the html and code,

    <ul class='tabs1'>
                    <li><a href='#tab1' id="allNews" runat="server" onserverclick="allNews_ServerClick">All News</a></li>
    
                    <li><a href='#tab2' id="forNgo" runat="server" onserverclick="forNgo_ServerClick">For NGO</a></li>
                    <li><a href='#tab3' id="fromNgo" runat="server" onserverclick="fromNgo_ServerClick">From NGO</a></li>
                </ul>

    Also see the code behind

    protected void allNews_ServerClick(object sender, EventArgs e)
            {
                // set user type accordingly in all below methods
                using (SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultCSRConnection"].ConnectionString))
                {
                    string query = "SELECT dbo.tbl_post.title, dbo.tbl_post.description, dbo.tbl_post.active, dbo.tbl_post.dateforPost, dbo.tbl_ngoname.ngo_desc, dbo.tbl_User.usertype FROM dbo.tbl_post INNER JOIN dbo.tbl_ngoname ON dbo.tbl_post.NgoId = dbo.tbl_ngoname.Id INNER JOIN dbo.tbl_User ON dbo.tbl_post.NgoId = dbo.tbl_User.NgoId where usertype in (0,1)";
                    SqlDataAdapter sda = new SqlDataAdapter(query, conn);
                    DataTable dt = new DataTable();
                    sda.Fill(dt);
                    lstNews.DataSource = dt;
                    lstNews.DataBind();
                }
            }
            protected void forNgo_ServerClick(object sender, EventArgs e)
            {
                using (SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultCSRConnection"].ConnectionString))
                {
                    string query = "SELECT dbo.tbl_post.title, dbo.tbl_post.description, dbo.tbl_post.active, dbo.tbl_post.dateforPost, dbo.tbl_ngoname.ngo_desc, dbo.tbl_User.usertype FROM dbo.tbl_post INNER JOIN dbo.tbl_ngoname ON dbo.tbl_post.NgoId = dbo.tbl_ngoname.Id INNER JOIN dbo.tbl_User ON dbo.tbl_post.NgoId = dbo.tbl_User.NgoId where usertype in (0,1)";
                    SqlDataAdapter sda = new SqlDataAdapter(query, conn);
                    DataTable dt = new DataTable();
                    sda.Fill(dt);
                    lstNews.DataSource = dt;
                    lstNews.DataBind();
                }
    
            }
            protected void fromNgo_ServerClick(object sender, EventArgs e)
            {
                
                using (SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultCSRConnection"].ConnectionString))
                {
                    string query = "SELECT dbo.tbl_post.title, dbo.tbl_post.description, dbo.tbl_post.active, dbo.tbl_post.dateforPost, dbo.tbl_ngoname.ngo_desc, dbo.tbl_User.usertype FROM  dbo.tbl_post INNER JOIN dbo.tbl_ngoname ON dbo.tbl_post.NgoId = dbo.tbl_ngoname.Id INNER JOIN dbo.tbl_User ON dbo.tbl_post.NgoId = dbo.tbl_User.NgoId where usertype=2";
                    SqlDataAdapter sda = new SqlDataAdapter(query, conn);
                    DataTable dt = new DataTable();
                    sda.Fill(dt);
                    lstNews.DataSource = dt;
                    lstNews.DataBind();
                }
            }

    For all the 3 tabs, I am getting the same data. Please help

     

    Wednesday, February 18, 2015 10:39 AM

Answers

  • User1577371250 posted
    protected void allNews_ServerClick(object sender, EventArgs e)
            {
                // set user type accordingly in all below methods
                using (SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultCSRConnection"].ConnectionString))
                {
                    string query = "SELECT dbo.tbl_post.title, dbo.tbl_post.description, dbo.tbl_post.active, dbo.tbl_post.dateforPost, dbo.tbl_ngoname.ngo_desc, dbo.tbl_User.usertype FROM dbo.tbl_post INNER JOIN dbo.tbl_ngoname ON dbo.tbl_post.NgoId = dbo.tbl_ngoname.Id INNER JOIN dbo.tbl_User ON dbo.tbl_post.NgoId = dbo.tbl_User.NgoId";
                    SqlDataAdapter sda = new SqlDataAdapter(query, conn);
                    DataTable dt = new DataTable();
                    sda.Fill(dt);
                    lstNews.DataSource = dt;
                    lstNews.DataBind();
                }
            }
            protected void forNgo_ServerClick(object sender, EventArgs e)
            {
                using (SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultCSRConnection"].ConnectionString))
                {
                    string query = "SELECT dbo.tbl_post.title, dbo.tbl_post.description, dbo.tbl_post.active, dbo.tbl_post.dateforPost, dbo.tbl_ngoname.ngo_desc, dbo.tbl_User.usertype FROM dbo.tbl_post INNER JOIN dbo.tbl_ngoname ON dbo.tbl_post.NgoId = dbo.tbl_ngoname.Id INNER JOIN dbo.tbl_User ON dbo.tbl_post.NgoId = dbo.tbl_User.NgoId where usertype != '2'";
                    SqlDataAdapter sda = new SqlDataAdapter(query, conn);
                    DataTable dt = new DataTable();
                    sda.Fill(dt);
                    lstNews.DataSource = dt;
                    lstNews.DataBind();
                }
    
            }
            protected void fromNgo_ServerClick(object sender, EventArgs e)
            {
                
                using (SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultCSRConnection"].ConnectionString))
                {
                    string query = "SELECT dbo.tbl_post.title, dbo.tbl_post.description, dbo.tbl_post.active, dbo.tbl_post.dateforPost, dbo.tbl_ngoname.ngo_desc, dbo.tbl_User.usertype FROM  dbo.tbl_post INNER JOIN dbo.tbl_ngoname ON dbo.tbl_post.NgoId = dbo.tbl_ngoname.Id INNER JOIN dbo.tbl_User ON dbo.tbl_post.NgoId = dbo.tbl_User.NgoId where usertype = '2'";
                    SqlDataAdapter sda = new SqlDataAdapter(query, conn);
                    DataTable dt = new DataTable();
                    sda.Fill(dt);
                    lstNews.DataSource = dt;
                    lstNews.DataBind();
                }
            }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 19, 2015 7:29 AM
  • User2103319870 posted

    A2H

    because your where condition is similar. You may need to change the condition accordingly

    So how to change the condition. I will let you know the tables query if you want.

    Try with the below code

     protected void allNews_ServerClick(object sender, EventArgs e)
            {
                // set user type accordingly in all below methods
                using (SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultCSRConnection"].ConnectionString))
                {
                    //Here fetch all news records
                    string query = "SELECT dbo.tbl_post.title, dbo.tbl_post.description, dbo.tbl_post.active, dbo.tbl_post.dateforPost, dbo.tbl_ngoname.ngo_desc, dbo.tbl_User.usertype FROM dbo.tbl_post INNER JOIN dbo.tbl_ngoname ON dbo.tbl_post.NgoId = dbo.tbl_ngoname.Id INNER JOIN dbo.tbl_User ON dbo.tbl_post.NgoId = dbo.tbl_User.NgoId where usertype in (0,1,2)";
                    SqlDataAdapter sda = new SqlDataAdapter(query, conn);
                    DataTable dt = new DataTable();
                    sda.Fill(dt);
                    lstNews.DataSource = dt;
                    lstNews.DataBind();
                }
            }
            protected void forNgo_ServerClick(object sender, EventArgs e)
            {
                using (SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultCSRConnection"].ConnectionString))
                {
                    //Here fetch only records which are of type 0,1
                    string query = "SELECT dbo.tbl_post.title, dbo.tbl_post.description, dbo.tbl_post.active, dbo.tbl_post.dateforPost, dbo.tbl_ngoname.ngo_desc, dbo.tbl_User.usertype FROM dbo.tbl_post INNER JOIN dbo.tbl_ngoname ON dbo.tbl_post.NgoId = dbo.tbl_ngoname.Id INNER JOIN dbo.tbl_User ON dbo.tbl_post.NgoId = dbo.tbl_User.NgoId where usertype in (0,1)";
                    SqlDataAdapter sda = new SqlDataAdapter(query, conn);
                    DataTable dt = new DataTable();
                    sda.Fill(dt);
                    lstNews.DataSource = dt;
                    lstNews.DataBind();
                }
    
            }
            protected void fromNgo_ServerClick(object sender, EventArgs e)
            {
    
                using (SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultCSRConnection"].ConnectionString))
                {
                    //Here fetch only records which are of type 2
                    string query = "SELECT dbo.tbl_post.title, dbo.tbl_post.description, dbo.tbl_post.active, dbo.tbl_post.dateforPost, dbo.tbl_ngoname.ngo_desc, dbo.tbl_User.usertype FROM  dbo.tbl_post INNER JOIN dbo.tbl_ngoname ON dbo.tbl_post.NgoId = dbo.tbl_ngoname.Id INNER JOIN dbo.tbl_User ON dbo.tbl_post.NgoId = dbo.tbl_User.NgoId where usertype=2";
                    SqlDataAdapter sda = new SqlDataAdapter(query, conn);
                    DataTable dt = new DataTable();
                    sda.Fill(dt);
                    lstNews.DataSource = dt;
                    lstNews.DataBind();
                }
            }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 19, 2015 9:40 AM

All replies

  • User2103319870 posted

     If you are concerned about allNews_ServerClick and forNgo_ServerClick then you may get same values because your where condition is similar. You may need to change the condition accordingly

    Wednesday, February 18, 2015 11:48 PM
  • User-1506965535 posted

    because your where condition is similar. You may need to change the condition accordingly

    So how to change the condition. I will let you know the tables query if you want.

    Thursday, February 19, 2015 12:42 AM
  • User1577371250 posted
    protected void allNews_ServerClick(object sender, EventArgs e)
            {
                // set user type accordingly in all below methods
                using (SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultCSRConnection"].ConnectionString))
                {
                    string query = "SELECT dbo.tbl_post.title, dbo.tbl_post.description, dbo.tbl_post.active, dbo.tbl_post.dateforPost, dbo.tbl_ngoname.ngo_desc, dbo.tbl_User.usertype FROM dbo.tbl_post INNER JOIN dbo.tbl_ngoname ON dbo.tbl_post.NgoId = dbo.tbl_ngoname.Id INNER JOIN dbo.tbl_User ON dbo.tbl_post.NgoId = dbo.tbl_User.NgoId";
                    SqlDataAdapter sda = new SqlDataAdapter(query, conn);
                    DataTable dt = new DataTable();
                    sda.Fill(dt);
                    lstNews.DataSource = dt;
                    lstNews.DataBind();
                }
            }
            protected void forNgo_ServerClick(object sender, EventArgs e)
            {
                using (SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultCSRConnection"].ConnectionString))
                {
                    string query = "SELECT dbo.tbl_post.title, dbo.tbl_post.description, dbo.tbl_post.active, dbo.tbl_post.dateforPost, dbo.tbl_ngoname.ngo_desc, dbo.tbl_User.usertype FROM dbo.tbl_post INNER JOIN dbo.tbl_ngoname ON dbo.tbl_post.NgoId = dbo.tbl_ngoname.Id INNER JOIN dbo.tbl_User ON dbo.tbl_post.NgoId = dbo.tbl_User.NgoId where usertype != '2'";
                    SqlDataAdapter sda = new SqlDataAdapter(query, conn);
                    DataTable dt = new DataTable();
                    sda.Fill(dt);
                    lstNews.DataSource = dt;
                    lstNews.DataBind();
                }
    
            }
            protected void fromNgo_ServerClick(object sender, EventArgs e)
            {
                
                using (SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultCSRConnection"].ConnectionString))
                {
                    string query = "SELECT dbo.tbl_post.title, dbo.tbl_post.description, dbo.tbl_post.active, dbo.tbl_post.dateforPost, dbo.tbl_ngoname.ngo_desc, dbo.tbl_User.usertype FROM  dbo.tbl_post INNER JOIN dbo.tbl_ngoname ON dbo.tbl_post.NgoId = dbo.tbl_ngoname.Id INNER JOIN dbo.tbl_User ON dbo.tbl_post.NgoId = dbo.tbl_User.NgoId where usertype = '2'";
                    SqlDataAdapter sda = new SqlDataAdapter(query, conn);
                    DataTable dt = new DataTable();
                    sda.Fill(dt);
                    lstNews.DataSource = dt;
                    lstNews.DataBind();
                }
            }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 19, 2015 7:29 AM
  • User-1506965535 posted

    It is not working, Even the OnServerClick is also not working 

    Thursday, February 19, 2015 8:11 AM
  • User2103319870 posted

    A2H

    because your where condition is similar. You may need to change the condition accordingly

    So how to change the condition. I will let you know the tables query if you want.

    Try with the below code

     protected void allNews_ServerClick(object sender, EventArgs e)
            {
                // set user type accordingly in all below methods
                using (SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultCSRConnection"].ConnectionString))
                {
                    //Here fetch all news records
                    string query = "SELECT dbo.tbl_post.title, dbo.tbl_post.description, dbo.tbl_post.active, dbo.tbl_post.dateforPost, dbo.tbl_ngoname.ngo_desc, dbo.tbl_User.usertype FROM dbo.tbl_post INNER JOIN dbo.tbl_ngoname ON dbo.tbl_post.NgoId = dbo.tbl_ngoname.Id INNER JOIN dbo.tbl_User ON dbo.tbl_post.NgoId = dbo.tbl_User.NgoId where usertype in (0,1,2)";
                    SqlDataAdapter sda = new SqlDataAdapter(query, conn);
                    DataTable dt = new DataTable();
                    sda.Fill(dt);
                    lstNews.DataSource = dt;
                    lstNews.DataBind();
                }
            }
            protected void forNgo_ServerClick(object sender, EventArgs e)
            {
                using (SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultCSRConnection"].ConnectionString))
                {
                    //Here fetch only records which are of type 0,1
                    string query = "SELECT dbo.tbl_post.title, dbo.tbl_post.description, dbo.tbl_post.active, dbo.tbl_post.dateforPost, dbo.tbl_ngoname.ngo_desc, dbo.tbl_User.usertype FROM dbo.tbl_post INNER JOIN dbo.tbl_ngoname ON dbo.tbl_post.NgoId = dbo.tbl_ngoname.Id INNER JOIN dbo.tbl_User ON dbo.tbl_post.NgoId = dbo.tbl_User.NgoId where usertype in (0,1)";
                    SqlDataAdapter sda = new SqlDataAdapter(query, conn);
                    DataTable dt = new DataTable();
                    sda.Fill(dt);
                    lstNews.DataSource = dt;
                    lstNews.DataBind();
                }
    
            }
            protected void fromNgo_ServerClick(object sender, EventArgs e)
            {
    
                using (SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultCSRConnection"].ConnectionString))
                {
                    //Here fetch only records which are of type 2
                    string query = "SELECT dbo.tbl_post.title, dbo.tbl_post.description, dbo.tbl_post.active, dbo.tbl_post.dateforPost, dbo.tbl_ngoname.ngo_desc, dbo.tbl_User.usertype FROM  dbo.tbl_post INNER JOIN dbo.tbl_ngoname ON dbo.tbl_post.NgoId = dbo.tbl_ngoname.Id INNER JOIN dbo.tbl_User ON dbo.tbl_post.NgoId = dbo.tbl_User.NgoId where usertype=2";
                    SqlDataAdapter sda = new SqlDataAdapter(query, conn);
                    DataTable dt = new DataTable();
                    sda.Fill(dt);
                    lstNews.DataSource = dt;
                    lstNews.DataBind();
                }
            }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 19, 2015 9:40 AM
  • User1577371250 posted

    Hi,

    1. My above C# code will do the separating the items for displaying in tabs.

    2. I think your JavaScript on Tabs are restricting the server side event.

    3. Check your java-script whether it is preventing the further execution.

    Thursday, February 19, 2015 9:40 AM
  • User-1506965535 posted

    Thanks lokesh, that worked. My javascript is not working properly that is why it was stopping it to work

    Thursday, February 19, 2015 9:42 AM
  • User-1506965535 posted

    Hi A2H,

    That worked for me but the issue is that the active of tabs is preventing to display properly. Have a look here

    http://forums.asp.net/p/2036726/5865375.aspx?p=True&t=635599356087722073

    Thursday, February 19, 2015 9:43 AM
  • User2103319870 posted

    Hi A2H,

    That worked for me but the issue is that the active of tabs is preventing to display properly. Have a look here

    http://forums.asp.net/p/2036726/5865375.aspx?p=True&t=635599356087722073

    Responded to the other thread. Please check it

    Thursday, February 19, 2015 9:53 AM