473,406 Members | 2,847 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Button on MasterPage Does Nothing

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

Oct 10 '07 #1
9 2718
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
Oct 10 '07 #2
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

Oct 10 '07 #3
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
Oct 10 '07 #4
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

Oct 10 '07 #5
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
Oct 10 '07 #6
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

Oct 11 '07 #7
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" <gu***@guffa.comwrote in message
news:uo**************@TK2MSFTNGP05.phx.gbl...
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
Oct 11 '07 #8
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" <gu***@guffa.comwrote in message
news:uo**************@TK2MSFTNGP05.phx.gbl...
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

Oct 16 '07 #9
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" <gu***@guffa.comwrote in message
news:uo**************@TK2MSFTNGP05.phx.gbl...
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

Oct 16 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: needin4mation | last post by:
protected void Page_Load(object sender, EventArgs e) { TextBox mpTextBox = (TextBox)(Master.FindControl("txtFreeSearch")); Response.Write("mp" + mpTextBox.Text); //only works the second time ...
1
by: hazz | last post by:
oh it hurts to be a newbie again....:-( I have a button click event I want to handle for a button to create an excel spreadsheet from gridview contents. I can't write the code for the button...
3
by: Tom | last post by:
I have a VS.NET 2005 WEB application where I place all of my common controls (ie header, nav, footer) into a mater page template. Then all of my web forms inherit from the mater page template. All...
4
by: cevans | last post by:
Is there a way to load a MasterPage programmatically? Not switch a page's masterpage but to create a MasterPage object that holds a given masterpage. So I know I can do: MasterPage master =...
7
by: Bon | last post by:
Dear all I create a master page with image buttons on the left-hand side for navigation. When a user clicks the student button, the content (i.e. ContentPlaceholder) in masterpage will be...
6
by: jelle.huygen | last post by:
Hello, I've worked on a website in ASP.NET 2.0 where, on every page, login- button of a login control is set as the default button. The login- control is on the masterpage of the website. In...
8
by: Randy Smith | last post by:
Hi, I now need to add MasterPages to a number of existing forms, but when I add the code for MasterPage, the MasterPage does NOT appear when it runs. Any thoughts? TIA, Randy Smith
5
by: bryanp10 | last post by:
Why does the @Register directive not carry over into templated pages? I have to @Register the user controls I want to use on every page... this seems contrary to the whole point of master pages to...
0
by: thersitz | last post by:
Hi, Using aspnet3.5,VStudio 2008, VB 1.) I have a set of pages, with a search text box button within a userControl that searches across our websites and is registered in a masterpage. 2)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.