473,836 Members | 1,467 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(obje ct sender, System.EventArg s e)
{
localhost.Servi ce1 WebServiceObjec t;
WebServiceObjec t = new localhost.Servi ce1();
string Result;
textBox1.Text = "This is a test Before the Try/Catch secion";
try
{
textBox1.Text = WebServiceObjec t.HelloWorld();
}
catch (Exception Ex)
{
textBox1.Text = "Web Service Exception: " + Ex.Message;
}
}
private void textBox1_TextCh anged(object sender, System.EventArg s 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 11567

did you add the event handler association also?

this.Load += new System.EventHan dler(this.Form1 _Load);

Alan.

Nov 21 '05 #2
<al*******@user s.com> wrote in message
news:11******** **************@ g43g2000cwa.goo glegroups.com.. .

did you add the event handler association also?

this.Load += new System.EventHan dler(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.EventHan dler(this.frmMa in_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.languag es.csharp
hth,
Alan.

Nov 21 '05 #4
<al*******@user s.com> wrote in message
news:11******** **************@ g47g2000cwa.goo glegroups.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.EventHan dler(this.frmMa in_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.languag es.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
10702
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. When I modified the file I also stopped and restarted the web server. Can anyone give me some ideas as to why it is not firing? Thanks
0
1695
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. When the login is successful login page writes back javascript
3
2308
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 WebApplication1 { using System;
7
4587
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 data was actually being edited. I am using bound textbox controls on the form. Could that have anything to do with it? Does anyone know how to stop the RowChanging events from firing? Thanks!
5
1844
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 Sub Not Firing the Enter Key event except Other Keys.
1
1532
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 to be firing either for each control that is loaded or it just seems to be firing off more then it should on a the page load.
19
10221
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 app using web application projects and it's firing fine but it was upgraded from the 1.1 framework. Why doesn't my global.asax application_error routine fire?
1
5063
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 testing this, I noticed that the OnCurrent event wasn't firing. I went to an older version of the program and saw that it wasn't firing there either. I don't know how long this has been going on, but it's quite distressing. To test the firing, I...
2
14571
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
9813
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9665
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
7782
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6976
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5645
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5817
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4446
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4006
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3108
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.