2

In my website No button event is firing.

<asp:Button ID="Button1" Text="Add_Record" runat="server"  AutoPostBack="true" 
                  onclick="Button1_Click"  />

when I write code in the event handler. It does not call. On every page of website I am facing this issue.

  <div id="eList">
        <p>Enter Your Email To Sign Up<br>
              For Our E-Newsletter:</p>
              <asp:TextBox ID="elist_input" runat="server" Width="169px">
              </asp:TextBox>
                  <br>
  <asp:Button class="elist_submit" runat="server" Text="Search" Width="56px"
      onclick="Unnamed1_Click" />

 <div id="display_menu_2">
        <asp:Button ID="Button1" Text="Add_Record" runat="server"
            AutoPostBack="true" onclick="Button1_Click"  />

Page Directive

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" 
    AutoEventWireup="true" CodeFile="HomePage.aspx.cs" Inherits="homePage" %>
7
  • 2
    Can you post your code? Does your asp:Button have an OnClick property set?
    – Matt
    Commented May 24, 2013 at 18:00
  • Kindly check the code. Commented May 24, 2013 at 19:19
  • Can you run any code behind or is it just events that don't work? If so, check your .aspx is correctly referencing the code behind. Commented May 24, 2013 at 19:21
  • i am redirecting on event call. but it's not working Commented May 24, 2013 at 19:23
  • Post your page directive - At the top '<%@Page' line. Also, post the C# or VB associated with these events. Also, technically the property should be 'OnClick', same casing.
    – Matt
    Commented May 24, 2013 at 20:01

2 Answers 2

1

Your project must have been Web application project and the CodeFile attribute is valid only in Web site project for compiled pages, change it to the CodeBehind like this.

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" 
AutoEventWireup="true" CodeBehind="HomePage.aspx.cs" Inherits="homePage" %>
3
  • when I change the codeFile attribute with codebehind. Now I am finding these errors.. could not load MasterPage, could not load viewcarts etc Commented May 25, 2013 at 17:49
  • What is the type of your project 'Web application' or 'Web site'? Commented May 26, 2013 at 5:03
  • I am develping a e-commerce web application of buying products. Commented May 26, 2013 at 9:29
0

I was not able to call the event handlers. the problem was due to the header.ascx file. In that file I used form and also a form in Master page. As Master page is inhereted to all pages and header is also. due to two form in one page event handlers were not working..

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.