473,320 Members | 1,990 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,320 software developers and data experts.

Button_Click change

Hi,

I'm using VS.NET 2002 with code behind.

If I add a button to the design and don't change the id,
i.e. 'Button1' but activates and write some code to the
click event and then later change the 'Button1' id
to 'btnSave' or something in designview, then I've tried
to change the Sub Button1_Click to btnSave_Click, but this
doesn't seem to work.

What and in which sequence should I do to have the new
btnSave_click event get up and work?

TIA

/Kenneth
Nov 17 '05 #1
4 1496
LIN
simple jus delete the code u have written for button1 's click event an then
go to design view and double click on the btnSave_Click button for the .vb
page to open where your cursor is in the on click event sub of tht button
...so can write ur click event code here
"Kenneth" <ke***********@chello.se> wrote in message
news:0b****************************@phx.gbl...
Hi,

I'm using VS.NET 2002 with code behind.

If I add a button to the design and don't change the id,
i.e. 'Button1' but activates and write some code to the
click event and then later change the 'Button1' id
to 'btnSave' or something in designview, then I've tried
to change the Sub Button1_Click to btnSave_Click, but this
doesn't seem to work.

What and in which sequence should I do to have the new
btnSave_click event get up and work?

TIA

/Kenneth

Nov 17 '05 #2
Change the ID of the button in nitializeComponent() function also to fire
the event.

--
Regards,
Yusuf D M
"LIN" <ju******************@football.com> wrote in message
news:ua**************@TK2MSFTNGP10.phx.gbl...
simple jus delete the code u have written for button1 's click event an then go to design view and double click on the btnSave_Click button for the .vb
page to open where your cursor is in the on click event sub of tht button
..so can write ur click event code here
"Kenneth" <ke***********@chello.se> wrote in message
news:0b****************************@phx.gbl...
Hi,

I'm using VS.NET 2002 with code behind.

If I add a button to the design and don't change the id,
i.e. 'Button1' but activates and write some code to the
click event and then later change the 'Button1' id
to 'btnSave' or something in designview, then I've tried
to change the Sub Button1_Click to btnSave_Click, but this
doesn't seem to work.

What and in which sequence should I do to have the new
btnSave_click event get up and work?

TIA

/Kenneth


Nov 17 '05 #3
A method is associated with the events (like clicks, updates etc) in two
ways...

the first is as mentioned by Yusuf,... the initialise component you'll see
the button and the event, and the method linked to this event, change this.
the second is that the method has the Handles operator on the back of it,
something like:

Private Sub button1_Click (ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles buttonOK.Click

It's either one or the other, I don't think it's both.

Hope that helps.
Dan.

"Kenneth" <ke***********@chello.se> wrote in message
news:0b****************************@phx.gbl...
Hi,

I'm using VS.NET 2002 with code behind.

If I add a button to the design and don't change the id,
i.e. 'Button1' but activates and write some code to the
click event and then later change the 'Button1' id
to 'btnSave' or something in designview, then I've tried
to change the Sub Button1_Click to btnSave_Click, but this
doesn't seem to work.

What and in which sequence should I do to have the new
btnSave_click event get up and work?

TIA

/Kenneth

Nov 17 '05 #4
In VS.Net, it is not necessary to make any change to the name of the Event
Handler, as the IDE will adjust the name of the control where it is
necessary. The name of the event handler is of no consequence, as long as it
references the correct name of the control for which it is designed.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
The more I learn, the less I know.

"Kenneth" <ke***********@chello.se> wrote in message
news:0b****************************@phx.gbl...
Hi,

I'm using VS.NET 2002 with code behind.

If I add a button to the design and don't change the id,
i.e. 'Button1' but activates and write some code to the
click event and then later change the 'Button1' id
to 'btnSave' or something in designview, then I've tried
to change the Sub Button1_Click to btnSave_Click, but this
doesn't seem to work.

What and in which sequence should I do to have the new
btnSave_click event get up and work?

TIA

/Kenneth

Nov 17 '05 #5

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

Similar topics

3
by: Tim Thomas | last post by:
Hi, I am very new to .NET and am in the process of building my first web application. I will briefly describe what i am trying to achieve: I have a system where suppliers register their...
2
by: Frank Schumacher | last post by:
Hi Folks, I have a problem with the order of events fired by ASP.NET. I found many articles which explaining the lifecycle of a site, but I found none which took the event from a Control on the...
3
by: I am Sam | last post by:
Please help. I'm dying here and pulling out the last few remaining elements of my hair over this. I have built a form that will identify and authenticate users. I keep getting the following...
9
by: gaddoznntp | last post by:
Hi all, I've a server button handling a button_click procedure. If the client user clicks the button, the page causes the postback and the button_click procedure is fired. Then, if the user...
13
by: Matt | last post by:
I am trying to call a recursive subroutine within a Button_Click event. How can I do this? I tried to create a seperate Function() but it will not allow me to use any variables that I created in...
1
by: Pushpadant Kacha via .NET 247 | last post by:
hi, I have an application where i am using a textbox and a submitbutton. the autopostback property of the textbox is set to true. now if there is a change in the textbox then thetexbox_changetext...
0
by: John | last post by:
I am loading my controls dynamically into my asp.net page. When I click on a button on one of those user controls then page reloads and I need to reload the page based on what has happened in the...
8
by: Marine | last post by:
Hi, Sorry i'm a newbie with Asp.net, here is my problem : private void Page_Load(object sender, System.EventArgs e) { if (IsPostBack) { Label1.Text = (string)Session; } } private void...
2
by: Cindy Lee | last post by:
I have an image button that I do an button_click with protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { stringt value1=TextBox1.Text; I get the value here ok, but only...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.