473,386 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

form1_Load not firing

I just started working with VS.net 2003 and am trying to get a Web Service
running. I got it working fine in VB.Net, but I can't seem to get it to go
to the Form_Load handler to call the service. From the book it is pretty
straight forward.

I added the form1_Load function to the default code:

************************************************** ******
static void Main()
{
Application.Run(new Form1());
}

private void Form1_Load(object sender, System.EventArgs e)
{
localhost.Service1 WebServiceObject;
WebServiceObject = new localhost.Service1();
string Result;
textBox1.Text = "This is a test Before the Try/Catch secion";
try
{
textBox1.Text = WebServiceObject.HelloWorld();
}
catch (Exception Ex)
{
textBox1.Text = "Web Service Exception: " + Ex.Message;
}
}
private void textBox1_TextChanged(object sender, System.EventArgs e)
{

}
}
}
************************************************** *********************

The program works fine and stepping through it goes first to Main but never
goes to Form1_Load.

The Form opens and the default text that was in the box is still there.

Why doesn't the Form1_Load handler work? The book doesn't mention having to
do anything special to get it to run. It says that when you first run the
application, the program will call the form's Load handler (Form1_Load).
Did it leave out a step?

Thanks,

Tom

Nov 21 '05 #1
4 11508

did you add the event handler association also?

this.Load += new System.EventHandler(this.Form1_Load);

Alan.

Nov 21 '05 #2
<al*******@users.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...

did you add the event handler association also?

this.Load += new System.EventHandler(this.Form1_Load);
I didn't put it in myself.

I assumed that since it was already there, that that handler would be there.

I was following an example from a book and they didn't mention it. They
said it would automatically go to that procedure. I assume that that was
wrong.

Where would I put this code?

Thanks,

Tom
Alan.

Nov 21 '05 #3

When one adds the Form Load event handler using the IDE - say by double
clicking on the form body in designer or using the dropdown to select
the load event, the IDE will add the empty routine AND add a line to
'Windows Form Designer Generated Code' region
//
// frmMain
//

....

this.Load += new System.EventHandler(this.frmMain_Load);

which associates the routine with the Load event.
The simplest solution is to

1) remove your load handler.
2) Double click on the form body to add a new load handler - with the
correct event/handler assoc.
3) copy the code from your routine to the new one
General point... this is the VB.Net rather than C# NG. You may get
better results posting the question to
micosoft.public.dotnet.languages.csharp
hth,
Alan.

Nov 21 '05 #4
<al*******@users.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...

When one adds the Form Load event handler using the IDE - say by double
clicking on the form body in designer or using the dropdown to select
the load event, the IDE will add the empty routine AND add a line to
'Windows Form Designer Generated Code' region
What was confusing is that I have the form_Load event set in the
properties/General/Startup Object. But it still went to Main first. I
would have thought it would set the handler there, but I guess not.


//
// frmMain
//

...

this.Load += new System.EventHandler(this.frmMain_Load);

which associates the routine with the Load event.
The simplest solution is to

1) remove your load handler.
2) Double click on the form body to add a new load handler - with the
correct event/handler assoc.
3) copy the code from your routine to the new one
General point... this is the VB.Net rather than C# NG. You may get
better results posting the question to
micosoft.public.dotnet.languages.csharp

Actually, I have been going back and forth between vb.net and C# in my
examples, so I don't even remember which project was causing me the problem.

I am used to coding my project directly using DW and am trying to get used
to the IDE to allow me to write Web Services and Windows Services. I was
going to wait for VS 2005, as I have heard that is much better and some
people don't like 2003, but I am under the gun here and had to bite the
bullet now.

Thanks,

Tom
hth,
Alan.

Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: qaz | last post by:
For some reason my global.asa file is not firing. I have it located in the root of my website (e.g., wwwroot\mywebsite\global.asa) and I have the web site configured as an "application" in IIS. ...
0
by: Ram | last post by:
I have a start page for my application default.htm which contains four frames. header.htm login.aspx rightside.htm footer.htm login.aspx conatins username, password fields and login button....
3
by: Mike | last post by:
Hi, I am adding controls dynamically in a WebForm, but none of these controls' events fire. Here is the class code I am using. I have tried so many things, but nothing works :-( namespace...
7
by: Denise | last post by:
I just realized the DataTable_RowChanging events were firing when I called Fill method of the DataAdapter! It fires TWICE for each row loaded. I thought these were only supposed to be called when...
5
by: Datagridtextboxcolumn not firing event | last post by:
"PLEASE HELP, I NEED HELP N O W !!!" AddHandler dgtxtboxcolumn.textbox.KeyDown, AddressOf TextBoxKeyPress Private Sub TextBoxKeyPress(ByVal sender as Object, ByVal e as KeyEventArgs) End...
1
by: thedotnetarchitect | last post by:
Can anyone tell me why my page load event is firing more then once? I have a asp.net 2.0 page with four user controls and it seems that the user controls are loading but the page load event seems...
19
by: furiousmojo | last post by:
This is a strange problem. I have a project where the contents of global.asax application_error are not firing. It is an asp.net 2.0 application using web application projects. I have another...
1
by: Diana | last post by:
I've got a database that has been working successfully for a number of years now. I just added a new item - basically a field that becomes visible depending on another field's value. When I was...
2
by: Carla Simeoni | last post by:
In general I have two procedures which are called at the beginning of a Form: Form1() { InitializeComponent(); ..... } and Form1_Load(); What is the difference ?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.