ASP: literal control usage

Source: Internet
Author: User
At the beginning, friends of. NET may not know the differences between literal and label. In fact, they only have one difference, that is, they are converting to the client html Code Label becomes <span> </span>, and literal does not contain any labels:
To manage video news on a website yesterday, first add a player to the page, as shown below: 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 Name = "Console" Value = "Clip1" >
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 can the player play different content based on the parameters we pass? The first line of the preceding HTML code specifies the source of the content played by the player. In order to play different content based on different parameters, we set the value to a literal control, then, in the Post code, it is OK to dynamically assign values to the text attribute of literal. 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 the object needs to be manually 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 video news content
Videocontent VC = Videocontent. Find (ID );

Lt_reader.text = VC. ANNOUNCER;
Lt_vdate.text = VC. vdate. to1_datestring ();
Lb_author.text = VC. Author;
Lt_resource.text = VC. resource;
Lb_title.text = VC. videotitle;

// Assign a value to the playback content
Lt_src.text = VC. linkurl;
}
}
}

The literal usage is very flexible. I hope the above 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.