Click here to Skip to main content
15,922,533 members
Please Sign up or sign in to vote.
1.80/5 (2 votes)
See more:
hi,
am developing a web application , web page is having tab control( am using ajax tabcontroltoolkit)
consists 6 tabs(add, edit delete.....)

when i select add tab (click OK button in add tab)it's working.
and when i select edit tab,delete....(click OK button in respective tabs) it's not working.(i was observed by keeping breakpoint in codebehind file)it's my tabcontrol page.
C#
<pre lang="c#"><%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Admin.aspx.cs" Inherits="Online_Billing_System.Admin" %>
<%@ Register Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit" tagPrefix="ajax" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1"  runat="server">
<title>Admin</title>
 <script type="text/javascript">
     function DeleteItem() {
         if (confirm("Are you sure you want to delete ...?")) {
             return true;
         }
         return false;
     }
 </script>

    <style type="text/css">
        .style1
        {
            width: 151px;
        }
    </style>
    
</head>
<body>
<form id="form1"  runat="server">
<ajax:ToolkitScriptManager ID="scriptmanager1"  runat="server">
</ajax:ToolkitScriptManager>
<div style=" width:89%">
<ajax:TabContainer ID="adminTabContainer"   runat="server"  ActiveTabIndex="0">
<ajax:TabPanel ID="tbpnladd"  runat="server" ><HeaderTemplate>
    
 Add Member

    </HeaderTemplate>
    
    <ContentTemplate>
        
        
   <asp:Panel ID="AddMem" runat="server" Width="738px">
        
        

        <table align="center" 
            style="width: 651px"><tr>
                
 <td></td><td align="right" ></td>
                
                
 <td align="center">Add Member </td></tr>
            
            
 <tr><td></td><td align="right" >Member ID: </td><td>
                
                
 <asp:TextBox ID="txtmemid" runat="server"></asp:TextBox></td>
                
                
 <td>
                    
                    

                    
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
            ErrorMessage=" Enter Member ID " ControlToValidate="txtmemid" 
            ForeColor="Red"></asp:RequiredFieldValidator></td></tr>
            
 <tr><td></td><td align="right" >Card ID: </td><td>
                
                
<asp:TextBox ID="txtcardid" runat="server" ></asp:TextBox></td>
                
                
 <td>
                    
                    

                    
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                ErrorMessage="Enter Card ID" ControlToValidate="txtcardid" ForeColor="Red"></asp:RequiredFieldValidator></td></tr>
            
            
<tr><td></td><td align="right">Name: </td><td>
                
                
 <asp:TextBox ID="txtname" runat="server"></asp:TextBox></td>
                
                
 <td>
                    
                    

                    
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="Enter Name" ControlToValidate="txtname" ForeColor="Red"></asp:RequiredFieldValidator></td></tr>
            
            
 <tr><td></td><td align="right">Date Of Membership: </td><td>
                
                

                
<asp:TextBox ID="txtdate" runat="server"  
       ></asp:TextBox>   </td><td>
                    
 <ajax:CalendarExtender  ID="calendar1" 
                    TargetControlID="txtdate"  runat="server" PopupButtonID="calendar" 
                    Format="yyyy-MM-dd" Enabled="True"></ajax:CalendarExtender></td>
    
                
                

    
            <td class="style1">
                
                

                
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="Enter Date Of Membership" ControlToValidate="txtdate" ForeColor="Red"></asp:RequiredFieldValidator></td></tr>
            
            
<tr><td></td><td align="right">Opening Balance: </td><td>
                
                
 <asp:TextBox ID="txtopenbal" runat="server"></asp:TextBox></td>
                
                
 <td>
                    
                    

                    
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ErrorMessage="Enter Opening Balance" ControlToValidate="txtopenbal" ForeColor="Red"></asp:RequiredFieldValidator></td></tr>
            
            
 <tr><td></td><td align="right" >Phone No: </td><td>
                
                
 <asp:TextBox ID="txtphone" runat="server"></asp:TextBox></td>
                
                
 <td>
                    
                    

<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ErrorMessage="Enter Phone No" ControlToValidate="txtphone" ForeColor="Red"></asp:RequiredFieldValidator></td></tr>
            
            
<tr><td></td><td align="right" >Address: </td><td align="left"><asp:TextBox ID="txtaddress" runat="server"></asp:TextBox></td><td>
                
                

<asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ErrorMessage="Enter Address" ControlToValidate="txtaddress" ForeColor="Red"></asp:RequiredFieldValidator></td></tr>
            
            
<tr><td></td><td align="right">Password:</td><td align="left">
                
                

                <asp:TextBox ID="txtpwd" runat="server" TextMode="Password"></asp:TextBox></td>
                
                
<td>
                    
                    

                    
<asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" ErrorMessage="Enter Password" ControlToValidate="txtpwd" ForeColor="Red"></asp:RequiredFieldValidator></td></tr>
            
            
 <tr><td></td><td align="right">Confirm Password</td><td align="left">
                
                

                <asp:TextBox ID="txtconfirmpwd" runat="server" TextMode="Password"></asp:TextBox></td><td>
                    
                    

<asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server" ErrorMessage="Enter Confirm Password" ControlToValidate="txtconfirmpwd" ForeColor="Red"></asp:RequiredFieldValidator></td>
                
                
 <td><asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="txtpwd" ControlToValidate="txtconfirmpwd" ErrorMessage="Passwords Don't Match" ForeColor="Red"></asp:CompareValidator></td></tr>
            
            
 <tr><td></td>
                
 <td></td><td align="left" >
                
                

    <asp:Button ID="btnok" runat="server" Text="OK" onclick="btnok_Click"/>
                
                

    <asp:Button ID="btncancel" runat="server" Text="Cancel" 
        OnClientClick="this.form.reset();return false;"/></td></tr></table></asp:Panel>
        

        
    </ContentTemplate>
    
    
</ajax:TabPanel>
<ajax:TabPanel ID="tbpnledit"  runat="server" ><HeaderTemplate>
    
 Edit Member

    </HeaderTemplate>
    
    <ContentTemplate>
        
        

    <asp:Panel ID="EditMem" runat="server" Width="570px">
        
<table align="center">
 <tr>
                
 <td align="right" colspan="2" ></td>
            
                
 <td>
 Edit Member </td></tr>
            
            
 <tr><td align="right" colspan="2">Member ID: </td>
                
                
 <td><asp:TextBox ID="txtememid" runat="server"></asp:TextBox>   </td></tr>
            
            
<tr><td align="right" colspan="2">Card ID: </td>
                
                
 <td>
                    
                    

        <asp:TextBox ID="txtecardid" runat="server" Width="112px"></asp:TextBox>   </td></tr>
            
            
 <tr> <td>
                
                
     <asp:Button ID="btneok" runat="server" Text="OK"  
        OnClick="btneok_Click" Font-Bold="True" Font-Names="Times New Roman" 
        Width="87px"/>   </td><td>
                    
                    

    <asp:Button ID="btnecancel" runat="server" Text="Cancel" 
        Width="96px" OnClientClick="this.form.reset();return false;" 
            OnClick="btnecancel_Click"/></td></tr></table></asp:Panel>
        

    </ContentTemplate>
    
    
</ajax:TabPanel>
    
<ajax:TabPanel ID="tbpnldelete"  runat="server" ><HeaderTemplate>
    
 Delete Member

    </HeaderTemplate>
    
    <ContentTemplate>
        
        

    <asp:Panel ID="DeleteMem" runat="server" Width="476px">
        
 <table align="center">
 <tr>
                
 <td></td>
 <td align="right" ></td>
            
                
 <td class="style1">Delete Member </td></tr>
            
            
 <tr><td></td><td align="right">Member ID: </td><td class="style1">
                
                

        <asp:TextBox ID="txtdmemid" runat="server" Height="21px" Width="112px"></asp:TextBox>   </td></tr>
            
            
<tr><td></td><td align="right">Card ID: </td><td class="style1"><asp:TextBox ID="txtdcardid" runat="server"></asp:TextBox>   </td></tr>
            
            
 <tr><td></td><td align="right">
                
                

    <asp:Button ID="btndok" runat="server" Text="OK" OnClick="btndok_Click" onclientclick="return DeleteItem()"/>   </td>
                
                
 <td class="style1">
                    
                    

        <asp:Button ID="btndcancel" runat="server" Text="Cancel" 
            onclick="btndcancel_Click" OnClientClick="this.form.reset();return false;" />   </td></tr></table></asp:Panel>
        
        

        
    </ContentTemplate>
    
    
</ajax:TabPanel>
<ajax:TabPanel ID="tbpnlview"  runat="server" ><HeaderTemplate>
    
 View Member

    </HeaderTemplate>
    
    <ContentTemplate>
        
        

    <asp:Panel ID="ViewMem" runat="server" Width="477px">
        
 <table align="center">
 <tr>
                
 <td></td>
<td align="right" ></td>
            
                
<td class="style1">View Member </td></tr>
            
            
<tr><td></td><td align="right">Member ID: </td><td class="style1"><asp:TextBox ID="txtvmemid" runat="server"></asp:TextBox>   </td></tr>
            
            
 <tr><td></td><td align="right">Card ID: </td><td class="style1"><asp:TextBox ID="txtvcardid" runat="server"></asp:TextBox>   </td></tr>
            
            
<tr><td></td><td align="right">
                
                

    <asp:Button ID="btnvok" runat="server" Text="OK" onclick="btnvok_Click" />   </td><td class="style1">
                    
                    
 <asp:Button ID="btnvcancel" runat="server" Text="Cancel" OnClientClick="this.form.reset();return false;"/>   </td></tr></table></asp:Panel>
        
        

    </ContentTemplate>
    
    
</ajax:TabPanel>
<ajax:TabPanel ID="tbpnlviewall"  runat="server" ><HeaderTemplate>
    
 View All

    </HeaderTemplate>
    
    <ContentTemplate>
        
        

        <asp:Panel ID="ViewAllMem" runat="server">
 <asp:GridView ID="viewallGridview" runat="server">
        </asp:GridView>
        </asp:Panel>
        


    </ContentTemplate>
    
    
</ajax:TabPanel>
<ajax:TabPanel ID="tbpnlsetting"  runat="server" ><HeaderTemplate>
    
 Settings
 
    </HeaderTemplate>
    
    <ContentTemplate>
        
        

    <asp:Panel ID="settings" runat="server" Width="530px">
        
 <table align="center">
<tr>
                
<td></td>
 <td align="right" ></td>
            
                
 <td class="style1">Change Password </td></tr>
            
            
 <tr><td></td><td align="right">Current Password: </td><td class="style1">
                
                

        <asp:TextBox ID="txtcupwd" runat="server" Height="21px" Width="112px"></asp:TextBox>   </td></tr>
            
            
 <tr><td></td><td align="right">New password: </td><td class="style1"><asp:TextBox ID="txtnewpwd" runat="server"></asp:TextBox>   </td></tr>
            
            
 <tr><td></td><td align="right">Reenter New password: </td><td class="style1"><asp:TextBox ID="txtreenterpwd" runat="server"></asp:TextBox>   </td></tr>
            
            
 <tr><td></td><td align="right">
                
                

    <asp:Button ID="btnsettingsok" runat="server" Text="OK" OnClick="btnsettingsok_Click" />   </td><td class="style1">
                    
                    

        <asp:Button ID="btnsettingscancel" runat="server" Text="Cancel" 
             OnClientClick="this.form.reset();return false;" />   </td></tr></table></asp:Panel>
        
   
    </ContentTemplate>
    
    
</ajax:TabPanel>
</ajax:TabContainer>
</div>
</form>
</body>
</html>
Posted
Comments
JoCodes 20-Jan-14 2:13am    
Its not working means the ok button click event in other tabs not even firing?
Member 10263519 20-Jan-14 2:50am    
yes, exactly but i wrote code for click events,
when i click the button from design it's moving to proper click event ,but in debugging it's not perfoming,why am not getting it.
am struggling a lot since one week

JoCodes 20-Jan-14 3:22am    
First check the Client side validations you are using. Since if any of the validators fail the click events wont fire ...

One of the reason can be the Validators used in the tab firing which prevents the Button Click event to postback. You can modify the Validators with a ValidationGroup to overcome this scenario.
 
Share this answer
 
Comments
Member 10263519 20-Jan-14 4:05am    
i wasn't used any validations for those tabs and their controls.
JoCodes 20-Jan-14 4:09am    
I can see validation controls being used from your posted code :)
Member 10263519 20-Jan-14 4:09am    
plz check out my code behind.
JoCodes 20-Jan-14 4:14am    
Its not related to code behind. If you use validation controls such as Requiredfield validators it will fire on postbacks so that the subsequent click events wont postback further. Thats why should be using validationgroups inorder to fire the Validation only on specific button clicks in particular tab panels only.
Member 10263519 20-Jan-14 4:41am    
it's ok plz give an example how to use validation groups
for perticular button.
plz don't mine check out : here is my code behind.
C#
<pre lang="c#">using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Configuration;
using MySql.Data.MySqlClient;

namespace Online_Billing_System
{
    public partial class Admin : System.Web.UI.Page
    {
        String ConnectionString = WebConfigurationManager.ConnectionStrings["myConnectionString"].ToString();

        protected void Page_Load(object sender, EventArgs e)
        {
        ////    //Page logindetails = Page.PreviousPage;
        //    //if (logindetails != null)
        //    //{
        //    //    TextBox usernametxt = (TextBox)logindetails.FindControl("txtuser");
        //    //    String username = usernametxt.Text;

        //    //    TextBox pwdtxt = (TextBox)logindetails.FindControl("txtpwd");
        //    //    String password = pwdtxt.Text;
        //    //}
            string s = Request.QueryString["UserName"];
            String x = Request.QueryString["Password"];

        }

        protected void btnok_Click(object sender, EventArgs e)
        {
            using (MySqlConnection con = new MySqlConnection(ConnectionString))
            {
                String query = "insert into admin(member_id,card_id,name,date_of_membership,opening_balance,phone_number,address,password,confirm_password) values(@memberid,@cardid,@name,@date,@balance,@phone,@address,@pwd,@confirmpwd)";
                MySqlCommand command = new MySqlCommand(query,con);
                command.Parameters.AddWithValue("@memberid", txtmemid.Text);
                command.Parameters.AddWithValue("@cardid", txtcardid.Text);
                command.Parameters.AddWithValue("@name", txtname.Text);
                command.Parameters.AddWithValue("@date", txtdate.Text);
                command.Parameters.AddWithValue("@balance", txtopenbal.Text);
                command.Parameters.AddWithValue("@phone", txtphone.Text);
                command.Parameters.AddWithValue("@address", txtaddress.Text);
                command.Parameters.AddWithValue("@pwd", txtpwd.Text);
                command.Parameters.AddWithValue("@confirmpwd", txtconfirmpwd.Text);
                con.Open();
                command.ExecuteNonQuery();

           }
            txtmemid.Text = "";
            txtcardid.Text = "";
            txtname.Text = "";
            txtdate.Text = "";
            txtopenbal.Text = "";
            txtphone.Text = "";
            txtaddress.Text = "";
           
        }

        //protected void btncancel_Click(object sender, EventArgs e)
        //{
            

        //    if (txtmemid.Text != "")
        //        txtmemid.Text = "";
        //    if (txtcardid.Text != "")
        //        txtcardid.Text = "";
        //    if (txtname.Text != "")
        //        txtname.Text = "";
        //    if (txtdate.Text != "")
        //        txtdate.Text = "";
        //    if (txtopenbal.Text != "")
        //        txtopenbal.Text = "";
        //    if (txtphone.Text != "")
        //        txtphone.Text = "";
        //    if (txtaddress.Text != "")
        //        txtaddress.Text = "";
        //    if (txtpwd.Text != "")
        //        txtpwd.Text = "";
        //    if (txtconfirmpwd.Text != "")
        //        txtconfirmpwd.Text = "";

        //}

       
        protected void btneok_Click(object sender, EventArgs e)
        {
            if (txtememid.Text != "" || txtecardid.Text != "")
                Response.Redirect("~/EditUser.aspx?memberid=" + txtememid.Text.Replace("&", "%26") +
                    "&cardid=" + txtecardid.Text.Replace("&", "%26"));
            else
            {
                Response.Write("<script type='text/javascript'>");
                Response.Write("alert('PLEASE ENTER EITHER MEMBER ID or CARD ID');");
                Response.Write("</script>");


            }
        }

        protected void btndok_Click(object sender, EventArgs e)
        {
            if (txtdmemid.Text != "" || txtdcardid.Text != "")
            {
                using (MySqlConnection con = new MySqlConnection(ConnectionString))
                {
                    String query = "delete from admin where member_id=@memid OR card_id=@card";
                    MySqlCommand command = new MySqlCommand(query, con);
                    command.Parameters.AddWithValue("@memid",txtdmemid.Text);
                    command.Parameters.AddWithValue("@card", txtdcardid.Text);
                    con.Open();
                    command.ExecuteNonQuery();

                }//connection
            }//if
            //else
            //{
            //    Response.Write("<script type='text/javascript'>");
            //    Response.Write("alert('PLEASE ENTER EITHER MEMBER ID or CARD ID');");
            //    Response.Write("</script>");


            //}
        }

        protected void btndcancel_Click(object sender, EventArgs e)
        {

        }

        protected void btnecancel_Click(object sender, EventArgs e)
        {

        }

        protected void btnvok_Click(object sender, EventArgs e)
        {
            if (txtvmemid.Text != "" || txtvcardid.Text != "")
            {
                Response.Redirect("~/View.aspx?memberid=" + txtememid.Text.Replace("&", "%26") +
                    "&cardid=" + txtecardid.Text.Replace("&", "%26"));

            }
            else {
                Response.Write("<script type='text/javascript'>");
                Response.Write("alert('PLEASE ENTER EITHER MEMBER ID or CARD ID');");
                Response.Write("</script>");

            }
        }

        protected void btnsettingsok_Click(object sender, EventArgs e)
        {
            using (MySqlConnection con = new MySqlConnection(ConnectionString))
            {
                String query = "select password from admin";
                MySqlCommand command = new MySqlCommand(query,con);
                con.Open();
                using (MySqlDataReader rdr = command.ExecuteReader())
                {
                    while (rdr.Read())
                    {
                        String currentpwd = txtcupwd.Text;
                        String dbpwd = rdr["password"].ToString();
                        if (currentpwd.Equals(dbpwd))
                        {
                            String query2 = "update admin set password=@pwd";
                            MySqlCommand com = new MySqlCommand(query2, con);
                            com.Parameters.AddWithValue("@pwd", txtcupwd.Text);
                            com.ExecuteNonQuery();
                        }
                        else {

                            Response.Write("<script type='text/javascript'>");
                            Response.Write("alert('Please Enter Correct Password');");
                            Response.Write("</script>");

                        }
                    
                    
                    }
                }
            
            }
        }

     
      }
}
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 25-Jan-14 2:50am    
Not an answer...
—SA

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