?
Solved

C# ASP.NET Buttons not firing on page

Posted on 2004-04-29
8
Medium Priority
?
1,232 Views
Last Modified: 2009-01-22
Hello,

I've an Admin web page which displays a Tabstrip control. On each tab strip page there is a Button

protected System.Web.UI.WebControls.Button btnChangePwd;
protected System.Web.UI.WebControls.Button btnUpdateParameters;
protected System.Web.UI.WebControls.Button btnChangePrivileges;

Each of these appears in the InitializeComponent section

this.btnChangePwd.Click += new System.EventHandler(this.btnChangePwd_Click);
this.btnUpdateParameters.Click += new System.EventHandler(this.btnUpdateParameters_Click);
this.btnChangePrivileges.Click += new System.EventHandler(this.btnChangePrivileges_Click);

and each of these do have a function behind each button which saves details to the database.

private void btnUpdateParameters_Click(object sender, System.EventArgs e)
{
|
}

When I had just btnChangePwd this button fired successfully. Now that I've enhanced this page, no buttons work when viewing in a web page. I can double click the button in design view, and the associated code is displayed for editing. Its like the association between the button and code doesnt exist. I've viewed the source when the page is displayed in a browser and can see no difference between that and buttons on other web pages.

I've also added a combo box, and the SelectedIndexChanged function works fine, updating associated radio buttons for me with uses permissions, so the code behind is working.

I don't understand why these buttons are failing to fire. I've compared this page to others that have buttons and I see no difference. Its the only page out of 15 where the buttons are failing to fire.

Any advice appreciated.

regards

Brian
0
Comment
Question by:obyapka
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 1

Author Comment

by:obyapka
ID: 10946700
btw,

I receive no error messages. I click the button and the page just sits there. I've but breakpoints on the relevant lines within the button code, and they haven't been reached, so I believe we are focusing on the link between button and code.

regards

Brian
0
 
LVL 21

Expert Comment

by:tovvenki
ID: 10947093
Hi,
 please check whether you have the following lines

this.btnChangePwd.Click += new System.EventHandler(this.btnChangePwd_Click);
this.btnUpdateParameters.Click += new System.EventHandler(this.btnUpdateParameters_Click);
this.btnChangePrivileges.Click += new System.EventHandler(this.btnChangePrivileges_Click);

in InitializeComponent section

Regards,
venki
0
 
LVL 1

Author Comment

by:obyapka
ID: 10947132
Venki,

I mentioned that they do in my initial message!

Don't know if this makes any difference, but this Admin page contains the TabStrip/MultiPage control. Each button is within a different page. When the page worked, I only had the one button, and no combo.

regards

Brian
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Accepted Solution

by:
Daeljan earned 1200 total points
ID: 10947337

Does it work if you set the 'CausesValidation' property of the button to false?
If so, the validators on the page are not allowing the action.
0
 
LVL 21

Expert Comment

by:tovvenki
ID: 10947677
Hi Brian,
Sorry I misunderstood that statement.
Have you placed the buttons in any containers because when a user clicks a button in a container control, the event message is bubbled to the container control, where it raises a container-specific event for e.g if the button is in the DataList control, a button often raises the DataList control's ItemCommand event (rather than a Button control's Click event).

I am sorry if this post is again not useful to you.

Regards,
Venki
0
 

Expert Comment

by:shekhar_k
ID: 10956871
In the Designer view go to the HTML view and then where the HTML tags for these buttons are defined check if runat=server attribute is present. If this attribute is not there then add it.

Moreover check if you have defined any function in the HTML tag like OnClick="btnUpdateParameters_Click", if you have any other function name apart from what you want the button to be associated with then change the function.
0
 
LVL 1

Author Comment

by:obyapka
ID: 10984242
Daeljan

thanks for pointing me towards the validators I have on my page. I find it odd that they're not working the way I expected, i.e. min value of 5 and max value of 25, refused anything between 5 and 9, but accepted 1 and 2... however if I input 2 digit numbers, i.e. 05-09 it works. Surely this is a bug with the range validator?

The range validators were messing with my buttons and this has now been resolved.

thanks

Brian
0
 
LVL 2

Expert Comment

by:Daeljan
ID: 10984247
Glad to have been of help!

Cheers
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question