Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Button on MasterPage Does Nothing

Reply
Thread Tools

Button on MasterPage Does Nothing

 
 
Jonathan Wood
Guest
Posts: n/a
 
      10-10-2007
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

 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?G=F6ran_Andersson?=
Guest
Posts: n/a
 
      10-10-2007
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
 
Reply With Quote
 
 
 
 
Jonathan Wood
Guest
Posts: n/a
 
      10-10-2007
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

 
Reply With Quote
 
=?ISO-8859-1?Q?G=F6ran_Andersson?=
Guest
Posts: n/a
 
      10-10-2007
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
 
Reply With Quote
 
David R. Longnecker
Guest
Posts: n/a
 
      10-10-2007
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
>>



 
Reply With Quote
 
=?ISO-8859-1?Q?G=F6ran_Andersson?=
Guest
Posts: n/a
 
      10-10-2007
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
 
Reply With Quote
 
Jonathan Wood
Guest
Posts: n/a
 
      10-11-2007
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

 
Reply With Quote
 
Jonathan Wood
Guest
Posts: n/a
 
      10-11-2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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


 
Reply With Quote
 
Jonathan Wood
Guest
Posts: n/a
 
      10-11-2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed). com...
> 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
>>>

>
>


 
Reply With Quote
 
=?Utf-8?B?Z3VpX2d1cnU=?=
Guest
Posts: n/a
 
      10-16-2007
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing a control on a masterpage that uses a second masterpage Torben Laursen ASP .Net 4 03-15-2008 03:27 AM
Masterpage change its masterpage mr t ASP .Net 0 08-29-2007 10:11 PM
MasterPages - take plain form, add MasterPage. MasterPage does NOT appear when run Randy Smith ASP .Net 9 04-14-2007 09:06 AM
MasterPage inheriting a MasterPage... is it possible? ThunderMusic ASP .Net 2 09-27-2006 07:57 PM
MasterPage -> Page -> MasterPage Code Access =?Utf-8?B?QWxleCBNYWdoZW4=?= ASP .Net 3 04-14-2006 12:34 PM



Advertisments