Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
i have the following MultiView coding
ASP.NET
<table>
               <tr>
                   <td>
                       <asp:Button ID="bt1" runat="server" Text="Tab 1" BorderStyle="None" CssClass="Initial" OnClick="bt1_Click" />
                       <asp:Button ID="bt2" runat="server" Text="Tab 2" BorderStyle="None" CssClass="Initial" OnClick="bt2_Click" />
                       <asp:MultiView ID="mainView" runat="server">
                           <asp:View ID="View1" runat="server">
                               <table style="width: 100%; border-width: 1px; border-color: #666; border-style: solid">
                                   <tr><td>
                                       <h3><span>View 1 </span></h3>
                                     </td></tr>
                               </table>
                           </asp:View>
                           <asp:View ID="View2" runat="server">
                               <table style="width: 100%; border-width: 1px; border-color: #666; border-style: solid">
                                   <tr><td><h3><span>View 2 </span></h3>
                                     </td></tr>
                               </table>
                           </asp:View>
                       </asp:MultiView></td></tr></table>

and c# coding is
C#
protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                bt1.CssClass = "Clicked";
                mainView.ActiveViewIndex = 0;                
            }
        }
protected void bt1_Click(object sender, EventArgs e)
        {
            bt1.CssClass = "Clicked";
            bt1.CssClass = "Initial";
            bt3.CssClass = "Initial";
            mainView.ActiveViewIndex = 0;        }
        protected void bt2_Click(object sender, EventArgs e)
        {
            bt1.CssClass = "Initial";
            bt2.CssClass = "Clicked";
            bt3.CssClass = "Initial";
            mainView.ActiveViewIndex = 1;
        }

when i run the project it give me the error which are (Compiler Error Message: CS1061: 'ASP.pages_default_aspx' does not contain a definition for 'bt1_Click' and no extension method 'bt1_Click' accepting a first argument of type 'ASP.pages_default_aspx' could be found (are you missing a using directive or an assembly reference?)
Posted
Updated 11-Aug-15 1:14am
v2
Comments
F-ES Sitecore 11-Aug-15 7:23am    
It sounds like the aspx page your code is on does not inherit the code-bind page you have posted. This could be because the Inherits tag is wrong, or there is something about your code you haven't told us such as you're using master pages and the control is on a master page and the code on the client page or vice versa.
Altaful Haq 11-Aug-15 7:44am    
yah i have a master page and these codes are an the content page...
F-ES Sitecore 11-Aug-15 7:54am    
And you didn't think that was relevant enough to mention? You'll probably have to attach your events via code rather than markup. Use Master.FindControl on your content page to find the button and add the click events programmatically. Google for "asp.net find controls on master page", "asp.net attach click event programmatically" if you don't know how to do these things.
Altaful Haq 11-Aug-15 7:45am    
<%@ Page Title="" Language="C#" MasterPageFile="~/CRMTrackingUser.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="CRMTracking.Pages.Default2" EnableEventValidation="false" %>
aarif moh shaikh 11-Aug-15 8:38am    
Just Double Click again on your bt1 . It will create this Click event again.

1 solution

It sounds like the aspx page your code is on does not inherit the code-bind page you have posted. This could be because the Inherits tag is wrong, or there is something about your code you haven't told us such as you're using master pages and the control is on a master page and the code on the client page or vice versa.
 
Share this answer
 

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