Button_Click() don't execute the code that it has, and doesn't give any exception

teixeira

Regular
Joined
Apr 5, 2005
Messages
94
Location
LEIRIA-PORTUGAL
Hi all

I'm developing an intranet application and on strange thing happened.
Until one hour that all the code worked ok all the button_clicks() and other events were ok and suddenly without a logical explanation the code for example in my buttons dont runs.
The page display all the information OK and when I click in the button it just doesn't runs the code I wrote, i tried breakpoints and replacing the buttons and paste the code and nothing,

Does this happenned to some of you?

I'm using ASP.NET 2.0 and C#

Thanks in advance,

Teixeira
 
You betcha :)

Let's say your button is named "Button1". In the "Web Form Designer generated code" there's a method named "InitializeComponent". In InitializeComponent, there should be a line that looks like
Code:
this.Button1.Click += new System.EventHandler(this.Button1_Click);
This is saying you want to execute a method named "Button1_Click" when you click Button1.

You should also have a method something like
Code:
private void Button1_Click(object sender, System.EventArgs e)
{
		
}
Make sure the button is wired to the right method name.

If that's not enough info for you, post your code so we can check it out.

Mike
 
mhildner said:
You betcha :)

Let's say your button is named "Button1". In the "Web Form Designer generated code" there's a method named "InitializeComponent". In InitializeComponent, there should be a line that looks like
Code:
this.Button1.Click += new System.EventHandler(this.Button1_Click);
This is saying you want to execute a method named "Button1_Click" when you click Button1.

You should also have a method something like
Code:
private void Button1_Click(object sender, System.EventArgs e)
{
		
}
Make sure the button is wired to the right method name.

If that's not enough info for you, post your code so we can check it out.

Mike


I can't find it, dont't forget i'm using ASP.NET Whidbey (2.0) in VS2005 Beta2.

I even can't find the InitializeComponent() in the page.
I can see that the codebehind file, has the name PARTIAL does it has any other file where that Method is stored?

The code behind file
Code:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class ferramentas_pesquisa_ind : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

	protected void btn_pesq_ferr_descri_Click(object sender, EventArgs e)
	{
	}
}
Thanks
 
Last edited:
Sorry, missed that part about 2.0. I was going to start a test project, but I don't even see a web app as an option in my Beta 2 ??? I usually do windows forms.

I know in a windows form project I have, the InitializeComponent is in a file underneath my form, named something like "MyForm.Designer.cs".

What happens when you double-click the button at design time? That should take you to the method that will execute when you click the button at run time.
 
mhildner said:
Sorry, missed that part about 2.0. I was going to start a test project, but I don't even see a web app as an option in my Beta 2 ??? I usually do windows forms.

I know in a windows form project I have, the InitializeComponent is in a file underneath my form, named something like "MyForm.Designer.cs".

What happens when you double-click the button at design time? That should take you to the method that will execute when you click the button at run time.

WebApp option dont appears in the main page where we usually choose the type of project as in VS2003, you have to choose. If i understood the question U have to do NEW->WebSite inspite of NEW->PROJECT as U usually do in vs2003.

When I double click the VS2005 switches to the codebehind file where i cant define my methods and access to the existing metods including this the ButtonClick() method.
And i just write my code and I run it.

The more strange is that i've another pages where all the code runs OK just this code doesn't run and I have the same things in both files. I tried to copy the control to a new file but it don't work.... very strange.

Anyway... if you have any more idea please post it.

Thanks a lot
 
Hey,

I didn´t find why it happened but making a new webform without copy & paste any control, creating all new it worked again.

Thanks the same for help

Nice weekend

Teixeira
 
Back
Top