locked
Event handler RRS feed

  • Question

  • User-1015922342 posted

    How does one specify events for items like buttons.

    Monday, November 13, 2017 2:20 PM

All replies

  • User753101303 posted

    Hi,

    You are using web pages coming from a web forms background ? Try https://docs.microsoft.com/en-us/aspnet/web-pages/overview/getting-started/introducing-aspnet-web-pages-2/form-basics#reading-form-values

    You are closer to the metal and you would check for Request.Form["MyButton"]. When a button is clicked, the text of the button is posted to the server using its name attribute as a key and the text of the button as a value (which usually you don't have really to test)...

    Monday, November 13, 2017 5:11 PM
  • User347430248 posted

    Hi herlhay,

    first you can try to open the .aspx page in design view.

    then you can add Button control from the Toolbox.

    then you can select the button with the help of Mouse.

    in the properties window , you will find the Events regarding Button control.

    you can select the desires event and event will be added in to the code behind.

    for example click event looks like below.

            protected void Button1_Click(object sender, EventArgs e)
            {
                // Add your code here...
            }

    you can refer link below will give you information about every events supported by Button control with code example.

    Button Events

    Regards

    Deepak

    Tuesday, November 14, 2017 1:31 AM