Skip to main content

SendingMessageEventArgs

Namespace: Wisej.Web.Ext.ChatControl

Assembly: Wisej.Web.Ext.ChatControl (4.1.0.0)

Provides data for the SendingMessage event.

public class SendingMessageEventArgs : EventArgs

Example:

private void chatBox_SendingMessage(object sender, SendingMessageEventArgs e)
{
if (e.IsChatBoxUser && e.Message.Content.Contains("password"))
e.Cancel = true;
}

Constructors​

Instance member SendingMessageEventArgs(isChatBoxUser, message)​

Initializes a new instance of the SendingMessageEventArgs class with the specified message.

NameTypeDescription
isChatBoxUserBooleantrue if the message is from the User; otherwise false.
messageMessageThe 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​

Instance member 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;
}

Instance member 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;
}

Instance member 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​

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