Professional Web Applications Themes

Button_Click change - ASP.NET General

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...

  1. #1

    Default 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
    Kenneth Guest

  2. #2

    Default 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" <se> wrote in message
    news:0b7c01c36888$9d602270$gbl... 


    LIN Guest

  3. #3

    Default Re: Button_Click change

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

    --
    Regards,


    Yusuf D M
    "LIN" <com> wrote in message
    news:phx.gbl... 
    then 
    >
    >[/ref]


    Yusuf Guest

  4. #4

    Default 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.EventArgs) Handles buttonOK.Click

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

    Hope that helps.
    Dan.

    "Kenneth" <se> wrote in message
    news:0b7c01c36888$9d602270$gbl... 


    Daniel Guest

  5. #5

    Default 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
    http://www.takempis.com
    The more I learn, the less I know.

    "Kenneth" <se> wrote in message
    news:0b7c01c36888$9d602270$gbl... 


    Kevin Guest

Similar Threads

  1. Button causes Form_Load to fire, before Button_Click
    By Paul Aspinall in forum ASP.NET General
    Replies: 1
    Last Post: August 12th, 07:12 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139