ASP.net:Literal Control Usage

Source: Internet
Author: User
Tags net
Asp.net| Control

Just started learning. NET friends may not know literal and label exactly what difference, in fact, they also have only one difference, that is, after the conversion to the client HTML code, label became <SPAN></SPAN> and literal is what mark does not take, the following goes to the point:
Yesterday to do a website video news management, first I want to add a player in the page, as follows:

1<object height=288 width=384 CLASSID=CLSID:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA VIEWASTEXT>
2<param name= "_extentx" value= "10160" ><param name= "_extenty" value= "7620" >
3<param name= "AUTOSTART" value= "-1" ><param name= "SHUFFLE" value= "0" >
4<param name= "PREFETCH" value= "0" ><param name= "nolabels" value= "0" >
5<param name= "SRC" value= "<asp:literal id= ' lt_src ' runat= ' server ' ></asp:Literal>" >
6<param name= "CONTROLS" value= "Imagewindow" ><param "CONSOLE" name= "value=" >
7<param name= "LOOP" value= "0" ><param name= "Numloop" value= "0" ><param name= "CENTER" value= "0" >
8<param name= "Maintainaspect" value= "0" ><param name= "BackgroundColor" value= "#000000" >
9</object>

So how do we get the player to play different things according to the parameters we pass? The 5th line of the preceding HTML code indicates the source of the content that the player is playing, and in order to be able to play different things depending on the parameters, we set the value to a literal control. Then it's OK to dynamically assign a value to the literal Text property in the back code. The code is as follows:

/**////<summary>
author:shy520
Http://pw.cnblogs.com
</summary>
public class ShowVideoContent:System.Web.UI.UserControl
{
protected System.Web.UI.WebControls.Literal Lt_reader;
protected System.Web.UI.WebControls.Literal lt_vdate;
protected System.Web.UI.WebControls.Literal Lb_author;
protected System.Web.UI.WebControls.Literal Lt_resource;
protected System.Web.UI.WebControls.Label Lb_title;
Note: The literal written in object require our hand-defined
Literal lt_src;
private void Page_Load (object sender, System.EventArgs e)
{
if (request.querystring["id"]!= null)
{
int id = Int. Parse (request.querystring["id"). ToString ());
Get the video news content
Videocontent VC = videocontent.find (ID);
Lt_reader. Text = VC. Announcer;
Lt_vdate. Text = VC. Vdate.toshortdatestring ();
Lb_author. Text = VC. Author;
Lt_resource. Text = VC. Resource;
Lb_title. Text = VC. Videotitle;
Assigning values to playback content
Lt_src. Text = VC. Linkurl;
}
}
}

The use of literal is very flexible, I hope the above said can help you!



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.