Solved

C# ASP.NET Buttons not firing on page

Posted on 2004-04-29
8
1,223 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
  • 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
 
LVL 2

Accepted Solution

by:
Daeljan earned 400 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

705 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now