We used an enumeration to get the operation and a user defined class OperationEventArgs to get the required arguments for the event.
In this article, we tried to create an event for the user control which will be raised on certain mathematical operations. When the button will be clicked, you will see the following output based on the supplied values. You can now run your application and provide values to the TextBox. Response.Write( string.Format( " The result of \"", e.OperationType, e.OperationResult)) In this event handler you will notice that we can access // the properties we created in the OperationEventArgs class // that will provide the values assigned to them while raising event / /// object /// OperationEventArgs protected void ctrlCalculator_Calculating( object sender, OperationEventArgs e)
NETCONTROL 2 CLIENT NOT CONNECTING.FOR.ALL USERS CODE
The code you need to place in the ASPX file looks like this:Ĭopy Code /// /// Event handler for the user defined event That's all to be done in the user control. (Operation.Division, Convert.ToDecimal( ) /Ĭonvert.ToDecimal( ))) performs the division operation and raise the event this.Calculating( this, new OperationEventArgs (Operation.Multiplicaiton, Convert.ToDecimal( ) performs the multiplication operation and raise the event this.Calculating( this, new OperationEventArgs (Operation.Subtraction, Convert.ToDecimal( ) performs the subtraction operation and raise the event this.Calculating( this, new OperationEventArgs (Operation.Addition, Convert.ToDecimal( ) In the following lines which will perform the mathematical operations // you will notice that a new object of OperationEventArgs is created // and the values are passed to its constructor // performs the addition operation and raise the event this.Calculating( this, new OperationEventArgs The following code creates a public event for the UserControl.Ĭopy Code protected void btnPerformOperation_Click( object sender, EventArgs e) The Home Assistant user/password/IP address must be entered in the MQTT NetControl settings. It is best to define a new user in the system, specifically for the login of MQTT clients. The user control in this example contains two TextBox controls and one Button. The MQTT broker uses home assistant's 'Users' system for authorization. You will understand the usage of these classes better when you will see them working in the example. / /// Property to get/set operation result / /// Property to get/set operation type / /// Operation /// decimal public OperationEventArgs(Operation operationType, decimal result) / /// Constructor with parameters to initialize values
/ public class OperationEventArgs : EventArgs Copy Code /// /// Class that will represent Operation related event arguments