Solved

C# ASP.NET Buttons not firing on page

Posted on 2004-04-29
8
1,227 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

775 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