LiteralControl Constructors
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Initializes a new instance of the LiteralControl class.
Overloads
LiteralControl() |
Initializes a new instance of the LiteralControl class that contains a literal string to be rendered on the requested ASP.NET page. |
LiteralControl(String) |
Initializes a new instance of the LiteralControl class with the specified text. |
LiteralControl()
Initializes a new instance of the LiteralControl class that contains a literal string to be rendered on the requested ASP.NET page.
public:
LiteralControl();
public LiteralControl ();
Public Sub New ()
Examples
The following code example creates a class, CustLiteralControlClass
, that extends the LiteralControl class. It creates an instance of the class named myLiteralControlClass1
by using the constructor that does not specify the text of the LiteralControl object. After the object is created, the Text property is used to set the text that it contains.
CustomLiteralControlClass myLiteralControlClass1=
new CustomLiteralControlClass();
myLiteralControlClass1.Text="This Control demonstrates the constructor1";
Dim myLiteralControlClass1 as CustomLiteralControlClass = _
new CustomLiteralControlClass()
myLiteralControlClass1.Text="This Control demonstrates the constructor1"
Applies to
LiteralControl(String)
Initializes a new instance of the LiteralControl class with the specified text.
public:
LiteralControl(System::String ^ text);
public LiteralControl (string text);
new System.Web.UI.LiteralControl : string -> System.Web.UI.LiteralControl
Public Sub New (text As String)
Parameters
- text
- String
The text to be rendered on the requested Web page.
Examples
The following code example creates two instances of the LiteralControl class using the LiteralControl constructor. The two instances render opening and closing tags for an H3 HTML element, and include the text to display within the H3 tags.
// Add two LiteralControls that render HTML H3 elements and text.
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")]
protected override void CreateChildControls() {
this.Controls.Add(new LiteralControl("<h3>Value: "));
TextBox box = new TextBox();
box.Text = "0";
this.Controls.Add(box);
this.Controls.Add(new LiteralControl("</h3>"));
}
' Add two LiteralControls that render HTML H3 elements and text.
<System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _
Protected Overrides Sub CreateChildControls()
Me.Controls.Add(New LiteralControl("<h3>Value: "))
Dim Box As New TextBox
Box.Text = "0"
Me.Controls.Add(box)
Me.Controls.Add(New LiteralControl("</h3>"))
End Sub
See also
Applies to
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기