Solved

C# ASP.NET Buttons not firing on page

Posted on 2004-04-29
8
1,229 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
Industry Leaders: 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 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
 
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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

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…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

726 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