asp:button event not firing

Discussion in 'ASP .Net' started by csgraham74, Sep 11, 2005.

  1. csgraham74

    csgraham74 Guest

    Hi guys,

    I posted regarding this issue the other day but i still dont have an
    answer to my problem.

    Basically i have imported asp.net pages from dreamweaver into visual
    studio. Ive added a few controls that ive copied in from another
    asp.net page that i built within visual studio. The problem is that the
    asp:button does not fir an event and therefore my code behind it wont
    work. The page load event is firing correctly so i think the issue
    relates only to the button.

    My button im using is the "btn_SearchNow" button. Can anyone tell me if
    im missing any code or if they have a workaround.


    Any help appreciated as i cannot seem to find a workaround.

    Imports System.IO
    Imports System.Data.OleDb
    Imports System.Configuration.ConfigurationSettings

    Public Class search
    Inherits System.Web.UI.Page
    Protected WithEvents Label9 As System.Web.UI.WebControls.Label
    Protected WithEvents ddl_SPropType As
    System.Web.UI.WebControls.DropDownList
    Protected WithEvents Label13 As System.Web.UI.WebControls.Label
    Protected WithEvents txt_SAddress As
    System.Web.UI.WebControls.TextBox
    Protected WithEvents lbl_TownCity As
    System.Web.UI.WebControls.Label
    Protected WithEvents ddl_STown As
    System.Web.UI.WebControls.DropDownList
    Protected WithEvents lbl_Postcode As
    System.Web.UI.WebControls.Label
    Protected WithEvents txt_SPostcode As
    System.Web.UI.WebControls.TextBox
    Protected WithEvents Label14 As System.Web.UI.WebControls.Label
    Protected WithEvents ddl_SRentBuy As
    System.Web.UI.WebControls.DropDownList
    Protected WithEvents lbl_SPropertyOfTheWeek As
    System.Web.UI.WebControls.Label
    Protected WithEvents ddl_SPropertyOfTheWeek As
    System.Web.UI.WebControls.DropDownList
    Protected WithEvents dg_Properties As
    System.Web.UI.WebControls.DataGrid
    Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
    Protected WithEvents Label6 As System.Web.UI.WebControls.Label
    '*********************************************
    Protected WithEvents btn_Searchnow As
    System.Web.UI.HtmlControls.HtmlInputImage
    '*********************************************
    Protected WithEvents Button1 As System.Web.UI.WebControls.Button
    Protected WithEvents Imagebutton1 As
    System.Web.UI.WebControls.ImageButton Protected WithEvents pnl_Grid As
    System.Web.UI.WebControls.Panel


    #Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub
    InitializeComponent()

    End Sub

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Init
    'CODEGEN: This method call is required by the Web Form Designer
    'Do not modify it using the code editor.
    InitializeComponent()
    End Sub

    #End Region
    csgraham74, Sep 11, 2005
    #1
    1. Advertising

  2. Does your event handler have the "Handles btn_SearchNow.Click" clause at the
    end of it? I have seen rare situations where this somehow gets automatically
    removed, I would double check to make sure it is still there. Another easy
    way to make sure something didn't accidentally get changed would be to
    double-click the button in Visual Studio's Design View to see if it is
    taking you to the place you think it should (If you changed the control's ID
    after creating the event handler the Handles clause is not automatically
    changed). Good Luck!
    --
    Nathan Sokalski

    http://www.nathansokalski.com/

    "csgraham74" <> wrote in message
    news:...
    > Hi guys,
    >
    > I posted regarding this issue the other day but i still dont have an
    > answer to my problem.
    >
    > Basically i have imported asp.net pages from dreamweaver into visual
    > studio. Ive added a few controls that ive copied in from another
    > asp.net page that i built within visual studio. The problem is that the
    > asp:button does not fir an event and therefore my code behind it wont
    > work. The page load event is firing correctly so i think the issue
    > relates only to the button.
    >
    > My button im using is the "btn_SearchNow" button. Can anyone tell me if
    > im missing any code or if they have a workaround.
    >
    >
    > Any help appreciated as i cannot seem to find a workaround.
    >
    > Imports System.IO
    > Imports System.Data.OleDb
    > Imports System.Configuration.ConfigurationSettings
    >
    > Public Class search
    > Inherits System.Web.UI.Page
    > Protected WithEvents Label9 As System.Web.UI.WebControls.Label
    > Protected WithEvents ddl_SPropType As
    > System.Web.UI.WebControls.DropDownList
    > Protected WithEvents Label13 As System.Web.UI.WebControls.Label
    > Protected WithEvents txt_SAddress As
    > System.Web.UI.WebControls.TextBox
    > Protected WithEvents lbl_TownCity As
    > System.Web.UI.WebControls.Label
    > Protected WithEvents ddl_STown As
    > System.Web.UI.WebControls.DropDownList
    > Protected WithEvents lbl_Postcode As
    > System.Web.UI.WebControls.Label
    > Protected WithEvents txt_SPostcode As
    > System.Web.UI.WebControls.TextBox
    > Protected WithEvents Label14 As System.Web.UI.WebControls.Label
    > Protected WithEvents ddl_SRentBuy As
    > System.Web.UI.WebControls.DropDownList
    > Protected WithEvents lbl_SPropertyOfTheWeek As
    > System.Web.UI.WebControls.Label
    > Protected WithEvents ddl_SPropertyOfTheWeek As
    > System.Web.UI.WebControls.DropDownList
    > Protected WithEvents dg_Properties As
    > System.Web.UI.WebControls.DataGrid
    > Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
    > Protected WithEvents Label6 As System.Web.UI.WebControls.Label
    > '*********************************************
    > Protected WithEvents btn_Searchnow As
    > System.Web.UI.HtmlControls.HtmlInputImage
    > '*********************************************
    > Protected WithEvents Button1 As System.Web.UI.WebControls.Button
    > Protected WithEvents Imagebutton1 As
    > System.Web.UI.WebControls.ImageButton Protected WithEvents pnl_Grid As
    > System.Web.UI.WebControls.Panel
    >
    >
    > #Region " Web Form Designer Generated Code "
    >
    > 'This call is required by the Web Form Designer.
    > <System.Diagnostics.DebuggerStepThrough()> Private Sub
    > InitializeComponent()
    >
    > End Sub
    >
    > Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles MyBase.Init
    > 'CODEGEN: This method call is required by the Web Form Designer
    > 'Do not modify it using the code editor.
    > InitializeComponent()
    > End Sub
    >
    > #End Region
    >
    Nathan Sokalski, Sep 11, 2005
    #2
    1. Advertising

  3. csgraham74

    csgraham74 Guest

    Thanks Nathan,

    I think the handles part gets lost when you move or cut and paste a
    control to another part of the page.

    Unfortunately i have the handles btn_SearchNow.click so thats not the
    problem

    Thanks for the help .

    any more ideas apprciated
    csgraham74, Sep 11, 2005
    #3
  4. I don't have any other ideas off hand. One thing I might suggest trying
    would be using Visual Studio's debug feature and put a Breakpoint right at
    the beginning of the event handler to see if the problem is with the handler
    actually getting called or with the code inside the event handler. Good
    Luck!
    --
    Nathan Sokalski

    http://www.nathansokalski.com/

    "csgraham74" <> wrote in message
    news:...
    > Thanks Nathan,
    >
    > I think the handles part gets lost when you move or cut and paste a
    > control to another part of the page.
    >
    > Unfortunately i have the handles btn_SearchNow.click so thats not the
    > problem
    >
    > Thanks for the help .
    >
    > any more ideas apprciated
    >
    Nathan Sokalski, Sep 11, 2005
    #4
  5. Nathan Sokalski wrote:
    > I don't have any other ideas off hand. One thing I might suggest
    > trying would be using Visual Studio's debug feature and put a
    > Breakpoint right at the beginning of the event handler to see if the
    > problem is with the handler actually getting called or with the code
    > inside the event handler. Good Luck!
    >


    I would also check to be sure that IsPostBack evaluates as you think it
    should. It could be that you are experiencing a problem that causes the
    runtime to think you're not in a postback when you actually are.

    --
    Jim Cheshire
    JIMCO Software
    http://www.jimcosoftware.com

    FrontPage add-ins for FrontPage 2000 - 2003
    JIMCO Software, Sep 11, 2005
    #5
  6. csgraham74

    csgraham74 Guest

    Actually got this sorted. Turned out that there was a form tag in the
    includes page but this just didnt throw an error. For whatever reason
    it did not allow the the event of the button to fire.


    Thanks for all the help

    CG
    csgraham74, Sep 17, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Max
    Replies:
    3
    Views:
    687
  2. Ken Cox [Microsoft MVP]

    Button Click event not firing

    Ken Cox [Microsoft MVP], Apr 28, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    1,525
    Andrea Williams
    Apr 28, 2004
  3. csgraham74

    asp:button control not firing event

    csgraham74, Sep 10, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    3,930
    csgraham74
    Sep 10, 2005
  4. Replies:
    7
    Views:
    12,406
  5. GauravGupta
    Replies:
    4
    Views:
    2,085
    Shilpa1234
    Jan 19, 2012
Loading...

Share This Page