AutoSizeLabel
Namespace: Wisej.Web.Ext.ChatControl
Assembly: Wisej.Web.Ext.ChatControl (4.1.0.0)
A Label that sizes itself on the client to fit its content.
- C#
- VB.NET
public class AutoSizeLabel : Label
Public Class AutoSizeLabel
Inherits Label
AutoSizeLabel is the default control used by Message to display its Content when no custom control is supplied through the RenderMessageControl event. HTML content is allowed by default (AllowHtml is set to true). The width and height are computed by the browser, constrained by the maximum size last passed to GetPreferredSize.
Example:
var label = new AutoSizeLabel
{
Text = "<b>Hello</b> from the chat!"
};
label.Size = label.GetPreferredSize(new Size(400, 0));
Constructors
AutoSizeLabel()
Initializes a new instance of AutoSizeLabel with AllowHtml enabled.
Example:
var label = new AutoSizeLabel();
label.Text = "Welcome to the <i>chat</i>.";
Methods
GetPreferredSize(proposedSize)
Retrieves the size of a rectangular area into which the label can be fitted and stores proposedSize as the maximum size used on the client.
| Parameter | Type | Description |
|---|---|---|
| proposedSize | Size | The custom-sized area for the label. A Width or Height greater than 0 is sent to the client as the maximum width or height; a value of 0 means unconstrained. |
Returns: Size. A Size representing the preferred width and height of the label.
The label's final size is determined by the browser; the returned value is the server-side estimate computed by the base Label implementation.
Example:
var label = new AutoSizeLabel { Text = "A long message that may wrap." };
// limit the label to 300 pixels wide, unconstrained height.
label.Size = label.GetPreferredSize(new Size(300, 0));
OnCreateControl()
Installs the client side script that resizes the label when the HTML text contains images.
OnWebRender(config)
| Parameter | Type | Description |
|---|---|---|
| config | Object |