SendingMessageEventArgs
Namespace: Wisej.Web.Ext.ChatControl
Assembly: Wisej.Web.Ext.ChatControl (4.1.0.0)
Provides data for the SendingMessage event.
- C#
- VB.NET
public class SendingMessageEventArgs : EventArgs
Public Class SendingMessageEventArgs
Inherits EventArgs
Example:
private void chatBox_SendingMessage(object sender, SendingMessageEventArgs e)
{
if (e.IsChatBoxUser && e.Message.Content.Contains("password"))
e.Cancel = true;
}
Constructors
SendingMessageEventArgs(isChatBoxUser, message)
Initializes a new instance of the SendingMessageEventArgs class with the specified message.
| Name | Type | Description |
|---|---|---|
| isChatBoxUser | Boolean | true if the message is from the User; otherwise false. |
| message | Message | The Message being sent. |
Example:
var message = new Message("Hello", null, chatBox.User);
var args = new SendingMessageEventArgs(true, message);
if (!args.Cancel)
chatBox.DataSource.Add(args.Message);
Properties
Cancel
Boolean: Returns or sets a value indicating whether to cancel processing the message.
Value: true to cancel the message; the default is false.
When this value is set to true, the related message will not be added to the chat container and the SentMessage event is not fired.
Example:
private void chatBox_SendingMessage(object sender, SendingMessageEventArgs e)
{
if (e.Message.Content.Length > 500)
e.Cancel = true;
}
IsChatBoxUser
Boolean: Returns whether the message is from the User.
Value: true if the message's User is the User; otherwise false.
SendingMessage is raised only for messages the user submits through the chat UI, which are always authored by the User, so this value is always true for that event.
Example:
private void chatBox_SendingMessage(object sender, SendingMessageEventArgs e)
{
// block messages that the current user sends with a banned word.
if (e.IsChatBoxUser && e.Message.Content.Contains("password"))
e.Cancel = true;
}
Message
Message: Returns the Message to be sent.
Example:
private void chatBox_SendingMessage(object sender, SendingMessageEventArgs e)
{
e.Message.Content = e.Message.Content.Trim();
}
Used By
| Name | Description |
|---|---|
| SendingMessageEventHandler | Represents the method that will handle the SendingMessage event, fired when the user submits a message through the chat UI, before it is added to the ChatBox. |