[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1239
  • Last Modified:

C# ASP.NET Buttons not firing on page

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
obyapka
Asked:
obyapka
  • 3
  • 2
  • 2
  • +1
1 Solution
 
obyapkaAuthor Commented:
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
 
tovvenkiCommented:
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
 
obyapkaAuthor Commented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
DaeljanCommented:

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
 
tovvenkiCommented:
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
 
shekhar_kCommented:
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
 
obyapkaAuthor Commented:
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
 
DaeljanCommented:
Glad to have been of help!

Cheers
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now