Button_Click change

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kenneth

    #1

    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
  • LIN

    #2
    Re: Button_Click change

    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" <kenneth.philp@ chello.se> wrote in message
    news:0b7c01c368 88$9d602270$a10 1280a@phx.gbl.. .[color=blue]
    > 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[/color]


    Comment

    • Yusuf D M

      #3
      Re: Button_Click change

      Change the ID of the button in nitializeCompon ent() function also to fire
      the event.

      --
      Regards,


      Yusuf D M
      "LIN" <junkvaluesnota llowed@football .com> wrote in message
      news:uarsBxIaDH A.2136@TK2MSFTN GP10.phx.gbl...[color=blue]
      > simple jus delete the code u have written for button1 's click event an[/color]
      then[color=blue]
      > 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" <kenneth.philp@ chello.se> wrote in message
      > news:0b7c01c368 88$9d602270$a10 1280a@phx.gbl.. .[color=green]
      > > 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[/color]
      >
      >[/color]


      Comment

      • Daniel Bass

        #4
        Re: Button_Click change

        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.EventArg s) Handles buttonOK.Click

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

        Hope that helps.
        Dan.

        "Kenneth" <kenneth.philp@ chello.se> wrote in message
        news:0b7c01c368 88$9d602270$a10 1280a@phx.gbl.. .[color=blue]
        > 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[/color]


        Comment

        • Kevin Spencer

          #5
          Re: Button_Click change

          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
          All hotels in Benidorm. The best selection of Benidorm hotels with reviews and maps. Book in advance and save.

          The more I learn, the less I know.

          "Kenneth" <kenneth.philp@ chello.se> wrote in message
          news:0b7c01c368 88$9d602270$a10 1280a@phx.gbl.. .[color=blue]
          > 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[/color]


          Comment

          Working...