locked
How To Add Event Handler? RRS feed

  • Question

  • User-1933134441 posted

    how to add event handler using asp.net c# webforms

    Tuesday, August 6, 2019 10:57 AM

Answers

  • User-1038772411 posted

    Hello, DevTeams

    Using the Attributes property of server side control.

    btnSubmit.Attributes.Add("onMouseOver","JavascriptCode();")
    

    Thanks.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 6, 2019 11:04 AM
  • User475983607 posted

    DevTeams

    was needed in c# code i have ado.net c# webform application.

    You have not answered the question.  ASP.NET Web Forms is an event driven framework where every page goes through the Page Life Cycle which is a series of default events.  Server controls also have events.  

    Is there any way you can explain the problem you are trying to solve at a high level?  Can you provide code that reproduces any issue you are having?

    Perhaps you need to go through a few Getting Started tutorials first?

    https://docs.microsoft.com/en-us/aspnet/web-forms/overview/getting-started/getting-started-with-aspnet-45-web-forms/introduction-and-overview

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 6, 2019 1:42 PM
  • User-719153870 posted

    Hi DevTeams,

    You can add client event handler in javascript like AddWeb Solution posted or you can add event handler to server controls with code.

    For exmaple, to add a click event handler to a button, you just need to double click the button in the "Design" view or add code "OnClick=<Create New Event >".

    You can see all the event you can add to a server control in the "properties"-"Events"(yellow lightning icon) browser in vs when you click the control like below:

    Best Regard,

    Yang Shen

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 7, 2019 5:15 AM

All replies

  • User-1038772411 posted

    Hello, DevTeams

    Using the Attributes property of server side control.

    btnSubmit.Attributes.Add("onMouseOver","JavascriptCode();")
    

    Thanks.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 6, 2019 11:04 AM
  • User475983607 posted

    DevTeams

    how to add event handler using asp.net c# webforms

    Can you clarify?  You wish to create a custom event handler or subscribe to an existing event handler like a click event?  What language are you using?  VB.NET or C#?  JavaScript?

    Tuesday, August 6, 2019 11:11 AM
  • User-1933134441 posted

    Hi, mgebhard

    was needed in c# code i have ado.net c# webform application.

    Thanks All.

    Tuesday, August 6, 2019 12:37 PM
  • User475983607 posted

    DevTeams

    was needed in c# code i have ado.net c# webform application.

    You have not answered the question.  ASP.NET Web Forms is an event driven framework where every page goes through the Page Life Cycle which is a series of default events.  Server controls also have events.  

    Is there any way you can explain the problem you are trying to solve at a high level?  Can you provide code that reproduces any issue you are having?

    Perhaps you need to go through a few Getting Started tutorials first?

    https://docs.microsoft.com/en-us/aspnet/web-forms/overview/getting-started/getting-started-with-aspnet-45-web-forms/introduction-and-overview

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 6, 2019 1:42 PM
  • User753101303 posted

    Hi,

    Try perhaps https://docs.microsoft.com/en-us/dotnet/standard/events/how-to-consume-events-in-a-web-forms-application which shows how to handle the click event for a button.

    If it doesn't help try to be more explicit about what you are looking for.

    Tuesday, August 6, 2019 1:51 PM
  • User-719153870 posted

    Hi DevTeams,

    You can add client event handler in javascript like AddWeb Solution posted or you can add event handler to server controls with code.

    For exmaple, to add a click event handler to a button, you just need to double click the button in the "Design" view or add code "OnClick=<Create New Event >".

    You can see all the event you can add to a server control in the "properties"-"Events"(yellow lightning icon) browser in vs when you click the control like below:

    Best Regard,

    Yang Shen

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 7, 2019 5:15 AM