Button on MasterPage Does Nothing

Discussion in 'ASP .Net' started by Jonathan Wood, Oct 10, 2007.

  1. Does anyone know of any reason a button on a master page would have no
    effect?

    I have a complex HTML page that I'm converting to ASP.NET, and acknowledge I
    could have something odd that is affecting this.

    But I'm stuck. My handler is in C# code and the code looks right. But
    absolutely nothing happens when I click the button.

    protected void Button1_Click(object sender, EventArgs e)
    {
    Button1.Text = "Button1_Click";
    }


    <p>
    <asp:Button runat="server" Text="Button" id="Button1"
    OnClick="Button1_Click" /></p>

    Thanks for any tips.

    --
    Jonathan Wood
    SoftCircuits Programming
    http://www.softcircuits.com
     
    Jonathan Wood, Oct 10, 2007
    #1
    1. Advertising

  2. Jonathan Wood wrote:
    > Does anyone know of any reason a button on a master page would have no
    > effect?
    >
    > I have a complex HTML page that I'm converting to ASP.NET, and
    > acknowledge I could have something odd that is affecting this.
    >
    > But I'm stuck. My handler is in C# code and the code looks right. But
    > absolutely nothing happens when I click the button.
    >
    > protected void Button1_Click(object sender, EventArgs e)
    > {
    > Button1.Text = "Button1_Click";
    > }
    >
    >
    > <p>
    > <asp:Button runat="server" Text="Button" id="Button1"
    > OnClick="Button1_Click" /></p>
    >
    > Thanks for any tips.
    >


    "Nothing" never happens. What exactly happens when you click the button?

    Does the button look like it reacts to the mouse click? I.e. does it's
    appearence change when you press the mouse button?

    Does the page do a postback or not when you click the button?

    --
    Göran Andersson
    _____
    http://www.guffa.com
     
    =?ISO-8859-1?Q?G=F6ran_Andersson?=, Oct 10, 2007
    #2
    1. Advertising

  3. Göran,

    > "Nothing" never happens. What exactly happens when you click the button?


    Nothing.

    > Does the button look like it reacts to the mouse click? I.e. does it's
    > appearence change when you press the mouse button?


    If I use a regular button, then Windows redraws it to appear pressed when I
    click it. If I use a bitmap button, the cursor changes to the hand pointer.
    Both controls also take the input focus when clicked. But I can detect
    absolutely nothing happening in response to a click.

    > Does the page do a postback or not when you click the button?


    Well if it did a postback, that would be something. There is no indication
    that it is doing a postback. The page doesn't flicker, it doesn't reset to
    the top of the page. And the button text does not change in response to my
    code.

    Jonathan
     
    Jonathan Wood, Oct 10, 2007
    #3
  4. Jonathan Wood wrote:
    > Göran,
    >
    >> "Nothing" never happens. What exactly happens when you click the button?

    >
    > Nothing.


    If that really is the case, then you have placed some other, invisible,
    element on top of the button so that it's impossible to click on.

    >> Does the button look like it reacts to the mouse click? I.e. does it's
    >> appearence change when you press the mouse button?

    >
    > If I use a regular button, then Windows redraws it to appear pressed
    > when I click it.


    That's not nothing. Something is actually happening when you click the
    button. That means that it's actually possible to click on the button,
    and that the button reacts to the click.

    > If I use a bitmap button, the cursor changes to the
    > hand pointer. Both controls also take the input focus when clicked. But
    > I can detect absolutely nothing happening in response to a click.


    That doesn't mean that nothing happens. The button reacts to the click,
    and that most likely means that the process of posting the form is
    started. I don't know yet why it doesn't succeed, but there is probably
    something in your page that stops it.

    Do you have any onsubmit event on the form?

    >> Does the page do a postback or not when you click the button?

    >
    > Well if it did a postback, that would be something. There is no
    > indication that it is doing a postback. The page doesn't flicker, it
    > doesn't reset to the top of the page. And the button text does not
    > change in response to my code.
    >
    > Jonathan


    --
    Göran Andersson
    _____
    http://www.guffa.com
     
    =?ISO-8859-1?Q?G=F6ran_Andersson?=, Oct 10, 2007
    #4
  5. I've seen this happen a few times... the Inherits string at the top of the
    master page doesn't match the code behind page for the master page:

    on the .Master page:

    '**********************************

    <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="TestMasterPage.master.cs"
    Inherits="SandBox.TestMasterPage" %>

    '**********************************

    On the .Master.cs page:

    '**********************************

    namespace SandBox // <------ HERE
    {
    public partial class TestMasterPage : System.Web.UI.MasterPage //
    <---- HERE
    {
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    }
    }

    '**********************************

    Make sure they match. If they don't, the OnClick will never be seen and
    the button will "press down", but since it doesn't see an associated event
    in the partial class, it just keeps on going (and won't throw an error =( ).

    -dl

    --
    David R. Longnecker
    http://blog.tiredstudent.com

    > Jonathan Wood wrote:
    >
    >> Göran,
    >>
    >>> "Nothing" never happens. What exactly happens when you click the
    >>> button?
    >>>

    >> Nothing.
    >>

    > If that really is the case, then you have placed some other,
    > invisible, element on top of the button so that it's impossible to
    > click on.
    >
    >>> Does the button look like it reacts to the mouse click? I.e. does
    >>> it's appearence change when you press the mouse button?
    >>>

    >> If I use a regular button, then Windows redraws it to appear pressed
    >> when I click it.
    >>

    > That's not nothing. Something is actually happening when you click the
    > button. That means that it's actually possible to click on the button,
    > and that the button reacts to the click.
    >
    >> If I use a bitmap button, the cursor changes to the hand pointer.
    >> Both controls also take the input focus when clicked. But I can
    >> detect absolutely nothing happening in response to a click.
    >>

    > That doesn't mean that nothing happens. The button reacts to the
    > click, and that most likely means that the process of posting the form
    > is started. I don't know yet why it doesn't succeed, but there is
    > probably something in your page that stops it.
    >
    > Do you have any onsubmit event on the form?
    >
    >>> Does the page do a postback or not when you click the button?
    >>>

    >> Well if it did a postback, that would be something. There is no
    >> indication that it is doing a postback. The page doesn't flicker, it
    >> doesn't reset to the top of the page. And the button text does not
    >> change in response to my code.
    >>
    >> Jonathan
    >>
     
    David R. Longnecker, Oct 10, 2007
    #5
  6. David R. Longnecker wrote:
    > I've seen this happen a few times... the Inherits string at the top of
    > the master page doesn't match the code behind page for the master page:
    >
    > on the .Master page:
    >
    > '**********************************
    >
    > <%@ Master Language="C#" AutoEventWireup="true"
    > CodeBehind="TestMasterPage.master.cs" Inherits="SandBox.TestMasterPage" %>
    >
    > '**********************************
    >
    > On the .Master.cs page:
    >
    > '**********************************
    >
    > namespace SandBox // <------ HERE
    > {
    > public partial class TestMasterPage : System.Web.UI.MasterPage //
    > <---- HERE
    > {
    > protected void Page_Load(object sender, EventArgs e)
    > {
    >
    > }
    > }
    > }
    >
    > '**********************************
    >
    > Make sure they match. If they don't, the OnClick will never be seen and
    > the button will "press down", but since it doesn't see an associated
    > event in the partial class, it just keeps on going (and won't throw an
    > error =( ).


    If that was the problem, the button would still cause a postback, but
    according to Jonathan that doesn't happen.

    --
    Göran Andersson
    _____
    http://www.guffa.com
     
    =?ISO-8859-1?Q?G=F6ran_Andersson?=, Oct 10, 2007
    #6
  7. Göran,

    > That's not nothing. Something is actually happening when you click the
    > button. That means that it's actually possible to click on the button, and
    > that the button reacts to the click.


    Yes, the button works at the Windows-level. That is, the code Windows uses
    to handle standard buttons is working, and the button is not disabled.

    That's fine if you want to call that something but, with respect to code
    running in response to that event, I see no indication of that.

    > Do you have any onsubmit event on the form?


    No.

    Jonathan
     
    Jonathan Wood, Oct 11, 2007
    #7
  8. BTW, of course it's possible something is happening in response to the
    button click event, I'm only saying there is no indication of that.

    If this were a desktop application, I'd popup a message. If I could run the
    site under Visual Studio (I can't), I'd set a break point. I'm just using
    Expression Web for this and, without Intellisense, I just don't know ASP.NET
    well enough to figure out how to verify the handler never gets called other
    than there is no sign of a postback and my handler code that changes the
    button's text appears to have no effect.

    Jonathan

    "Göran Andersson" <> wrote in message
    news:...
    > Jonathan Wood wrote:
    >> Göran,
    >>
    >>> "Nothing" never happens. What exactly happens when you click the button?

    >>
    >> Nothing.

    >
    > If that really is the case, then you have placed some other, invisible,
    > element on top of the button so that it's impossible to click on.
    >
    >>> Does the button look like it reacts to the mouse click? I.e. does it's
    >>> appearence change when you press the mouse button?

    >>
    >> If I use a regular button, then Windows redraws it to appear pressed when
    >> I click it.

    >
    > That's not nothing. Something is actually happening when you click the
    > button. That means that it's actually possible to click on the button, and
    > that the button reacts to the click.
    >
    >> If I use a bitmap button, the cursor changes to the hand pointer. Both
    >> controls also take the input focus when clicked. But I can detect
    >> absolutely nothing happening in response to a click.

    >
    > That doesn't mean that nothing happens. The button reacts to the click,
    > and that most likely means that the process of posting the form is
    > started. I don't know yet why it doesn't succeed, but there is probably
    > something in your page that stops it.
    >
    > Do you have any onsubmit event on the form?
    >
    >>> Does the page do a postback or not when you click the button?

    >>
    >> Well if it did a postback, that would be something. There is no
    >> indication that it is doing a postback. The page doesn't flicker, it
    >> doesn't reset to the top of the page. And the button text does not change
    >> in response to my code.
    >>
    >> Jonathan

    >
    > --
    > Göran Andersson
    > _____
    > http://www.guffa.com
     
    Jonathan Wood, Oct 11, 2007
    #8
  9. Here's the header in my default.aspx:

    <%@ Page Language="C#" masterpagefile="cygnus.master" title="Cygnus Hex
    Editor" %>
    <%@ MasterType VirtualPath = "cygnus.master" %>

    And here's the header in my cygnus.master:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
    <%@ Master Language="C#" %>
    <%@ Import Namespace="System.Net" %>
    <%@ Import Namespace="System.IO" %>
    <%@ Import Namespace="System.Diagnostics" %>

    The buttons in question on defined on the master page, and the handler is
    defined as server-side script on the master page (no separate code file).

    So that doesn't appear to be the issue unless I'm missing something.

    Jonathan

    "David R. Longnecker" <> wrote in message
    news:...
    > I've seen this happen a few times... the Inherits string at the top of the
    > master page doesn't match the code behind page for the master page:
    >
    > on the .Master page:
    >
    > '**********************************
    >
    > <%@ Master Language="C#" AutoEventWireup="true"
    > CodeBehind="TestMasterPage.master.cs" Inherits="SandBox.TestMasterPage" %>
    >
    > '**********************************
    >
    > On the .Master.cs page:
    >
    > '**********************************
    >
    > namespace SandBox // <------ HERE
    > {
    > public partial class TestMasterPage : System.Web.UI.MasterPage //
    > <---- HERE
    > {
    > protected void Page_Load(object sender, EventArgs e)
    > {
    >
    > }
    > }
    > }
    >
    > '**********************************
    >
    > Make sure they match. If they don't, the OnClick will never be seen and
    > the button will "press down", but since it doesn't see an associated event
    > in the partial class, it just keeps on going (and won't throw an error
    > =( ).
    >
    > -dl
    >
    > --
    > David R. Longnecker
    > http://blog.tiredstudent.com
    >
    >> Jonathan Wood wrote:
    >>
    >>> Göran,
    >>>
    >>>> "Nothing" never happens. What exactly happens when you click the
    >>>> button?
    >>>>
    >>> Nothing.
    >>>

    >> If that really is the case, then you have placed some other,
    >> invisible, element on top of the button so that it's impossible to
    >> click on.
    >>
    >>>> Does the button look like it reacts to the mouse click? I.e. does
    >>>> it's appearence change when you press the mouse button?
    >>>>
    >>> If I use a regular button, then Windows redraws it to appear pressed
    >>> when I click it.
    >>>

    >> That's not nothing. Something is actually happening when you click the
    >> button. That means that it's actually possible to click on the button,
    >> and that the button reacts to the click.
    >>
    >>> If I use a bitmap button, the cursor changes to the hand pointer.
    >>> Both controls also take the input focus when clicked. But I can
    >>> detect absolutely nothing happening in response to a click.
    >>>

    >> That doesn't mean that nothing happens. The button reacts to the
    >> click, and that most likely means that the process of posting the form
    >> is started. I don't know yet why it doesn't succeed, but there is
    >> probably something in your page that stops it.
    >>
    >> Do you have any onsubmit event on the form?
    >>
    >>>> Does the page do a postback or not when you click the button?
    >>>>
    >>> Well if it did a postback, that would be something. There is no
    >>> indication that it is doing a postback. The page doesn't flicker, it
    >>> doesn't reset to the top of the page. And the button text does not
    >>> change in response to my code.
    >>>
    >>> Jonathan
    >>>

    >
    >
     
    Jonathan Wood, Oct 11, 2007
    #9
  10. I have the same (or similar) issue. The button in question is not on a master
    page but the symptom is the same. The button appears to be getting clicked
    but no code executes (oninit, onload, onclick, etc). Other buttons on the
    page work fine.

    Run the same code in VS on a machine running the same version of everything
    (Windows, IE, VS, IIS, SP's, etc.) and the button works as expected. If I
    publish the website on my machine, it runs correctly on other machines but
    not on mine.

    My solution is to not click the button on my machine. ;~o

    "Jonathan Wood" wrote:

    > BTW, of course it's possible something is happening in response to the
    > button click event, I'm only saying there is no indication of that.
    >
    > If this were a desktop application, I'd popup a message. If I could run the
    > site under Visual Studio (I can't), I'd set a break point. I'm just using
    > Expression Web for this and, without Intellisense, I just don't know ASP.NET
    > well enough to figure out how to verify the handler never gets called other
    > than there is no sign of a postback and my handler code that changes the
    > button's text appears to have no effect.
    >
    > Jonathan
    >
    > "Göran Andersson" <> wrote in message
    > news:...
    > > Jonathan Wood wrote:
    > >> Göran,
    > >>
    > >>> "Nothing" never happens. What exactly happens when you click the button?
    > >>
    > >> Nothing.

    > >
    > > If that really is the case, then you have placed some other, invisible,
    > > element on top of the button so that it's impossible to click on.
    > >
    > >>> Does the button look like it reacts to the mouse click? I.e. does it's
    > >>> appearence change when you press the mouse button?
    > >>
    > >> If I use a regular button, then Windows redraws it to appear pressed when
    > >> I click it.

    > >
    > > That's not nothing. Something is actually happening when you click the
    > > button. That means that it's actually possible to click on the button, and
    > > that the button reacts to the click.
    > >
    > >> If I use a bitmap button, the cursor changes to the hand pointer. Both
    > >> controls also take the input focus when clicked. But I can detect
    > >> absolutely nothing happening in response to a click.

    > >
    > > That doesn't mean that nothing happens. The button reacts to the click,
    > > and that most likely means that the process of posting the form is
    > > started. I don't know yet why it doesn't succeed, but there is probably
    > > something in your page that stops it.
    > >
    > > Do you have any onsubmit event on the form?
    > >
    > >>> Does the page do a postback or not when you click the button?
    > >>
    > >> Well if it did a postback, that would be something. There is no
    > >> indication that it is doing a postback. The page doesn't flicker, it
    > >> doesn't reset to the top of the page. And the button text does not change
    > >> in response to my code.
    > >>
    > >> Jonathan

    > >
    > > --
    > > Göran Andersson
    > > _____
    > > http://www.guffa.com

    >
    >
     
    =?Utf-8?B?Z3VpX2d1cnU=?=, Oct 16, 2007
    #10
  11. Sorry about the last message, I forgot to add the real reason for the
    problem. In my case, it was due to the fact that the POSTDATA size was too
    large (app error in eventvwr). The reason it appeared to work on one machine
    and not another was that the file being uploaded from my machine was larger
    than the file being uploaded on the other machines.

    "Jonathan Wood" wrote:

    > BTW, of course it's possible something is happening in response to the
    > button click event, I'm only saying there is no indication of that.
    >
    > If this were a desktop application, I'd popup a message. If I could run the
    > site under Visual Studio (I can't), I'd set a break point. I'm just using
    > Expression Web for this and, without Intellisense, I just don't know ASP.NET
    > well enough to figure out how to verify the handler never gets called other
    > than there is no sign of a postback and my handler code that changes the
    > button's text appears to have no effect.
    >
    > Jonathan
    >
    > "Göran Andersson" <> wrote in message
    > news:...
    > > Jonathan Wood wrote:
    > >> Göran,
    > >>
    > >>> "Nothing" never happens. What exactly happens when you click the button?
    > >>
    > >> Nothing.

    > >
    > > If that really is the case, then you have placed some other, invisible,
    > > element on top of the button so that it's impossible to click on.
    > >
    > >>> Does the button look like it reacts to the mouse click? I.e. does it's
    > >>> appearence change when you press the mouse button?
    > >>
    > >> If I use a regular button, then Windows redraws it to appear pressed when
    > >> I click it.

    > >
    > > That's not nothing. Something is actually happening when you click the
    > > button. That means that it's actually possible to click on the button, and
    > > that the button reacts to the click.
    > >
    > >> If I use a bitmap button, the cursor changes to the hand pointer. Both
    > >> controls also take the input focus when clicked. But I can detect
    > >> absolutely nothing happening in response to a click.

    > >
    > > That doesn't mean that nothing happens. The button reacts to the click,
    > > and that most likely means that the process of posting the form is
    > > started. I don't know yet why it doesn't succeed, but there is probably
    > > something in your page that stops it.
    > >
    > > Do you have any onsubmit event on the form?
    > >
    > >>> Does the page do a postback or not when you click the button?
    > >>
    > >> Well if it did a postback, that would be something. There is no
    > >> indication that it is doing a postback. The page doesn't flicker, it
    > >> doesn't reset to the top of the page. And the button text does not change
    > >> in response to my code.
    > >>
    > >> Jonathan

    > >
    > > --
    > > Göran Andersson
    > > _____
    > > http://www.guffa.com

    >
    >
     
    =?Utf-8?B?Z3VpX2d1cnU=?=, Oct 16, 2007
    #11
    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. =?Utf-8?B?QWxleCBNYWdoZW4=?=

    MasterPage -> Page -> MasterPage Code Access

    =?Utf-8?B?QWxleCBNYWdoZW4=?=, Apr 10, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    7,922
    Steven Cheng[MSFT]
    Apr 14, 2006
  2. ThunderMusic
    Replies:
    2
    Views:
    463
    Gregory Gadow
    Sep 27, 2006
  3. Randy Smith
    Replies:
    9
    Views:
    450
    Mark Rae
    Apr 14, 2007
  4. mr t
    Replies:
    0
    Views:
    417
  5. Devin Jeanpierre
    Replies:
    2
    Views:
    492
    Devin Jeanpierre
    Feb 14, 2012
Loading...

Share This Page