Self-compiled news display controls (list display is not complete yet and efforts need to be made)

Source: Internet
Author: User

Namespace tyj. Control
{
Using System;
Using System. Data;
Using System. Drawing;
Using System. Web;
Using System. Web. UI. WebControls;
Using System. Web. UI. HtmlControls;
Using System. Data. SqlClient;
Using System. Text;
Using BLL; // reference the custom business logic layer

/// <Summary>
/// Summary of bmxshow.
/// BMX English Web 'bussiness code class
/// Control code of BMX English website
/// By: http://www.itelite.cn
/// Time: 2007-10-25
/// </Summary>
Public class bmxshow: System. Web. UI. UserControl
{

Protected BMX_EN bmx_en = new BMX_EN (); // define a Business Object

Protected PagedDataSource PPS = new PagedDataSource (); // defines a paging record set
Protected DataSet ds = new DataSet ();
Protected DataTable dt = new DataTable ();

Private string navurl; // whether the paging tool button is displayed
Private bool dateshow; // whether to display the date
Private string newstype; // category of news displayed
Private int showsum;
Public string NavUrl {
Set {
Navurl = value;
}
Get {
Return navurl;
}
}
Public bool DateShow {
Set {
Dateshow = value;
}
Get {
Return dateshow;
}
 
}
Public string NewsType {
Set {
Newstype = value;
}
Get {
Return newstype;
}
}
Public int ShowSum {// number of records displayed
Set {
Showsum = value;
}
Get {
Return showsum;
}
}

Private void Page_Load (object sender, System. EventArgs e)
{
// Place user code here to initialize the page
Shownews ();
}

# Code generated by region Web Form Designer
Override protected void OnInit (EventArgs e)
{
//
// CODEGEN: This call is required by the ASP. NET Web form designer.
//
InitializeComponent ();
Base. OnInit (e );
}

/// <Summary>
/// The designer supports the required methods-do not use the code editor
/// Modify the content of this method.
/// </Summary>
Private void InitializeComponent ()
{
This. Load + = new System. EventHandler (this. Page_Load );

}
# Endregion

# Region self-compiled x
Protected void shownews ()
{
Ds = bmx_en.GetNewsList ("news_en", newstype );
Dt = ds. Tables [0];

If (showsum> dt. Rows. Count & showsum>-1)
{Showsum = dt. Rows. Count ;}
Else if (showsum <0)
{Showsum = 0 ;}
Response. Write ("<ul> ");
For (int I = 0; I <showsum; I ++)
{
HyperLink url = new HyperLink ();
// Response. Write ("<li> ");
Response. Write ("<li> <a href =" + navurl + "? Id = "+ dt. rows [I] ["newsid"]. toString () + ">" + dt. rows [I] ["newstitle"]. toString () + "_ hahha" + dt. rows [I] [2]. toString () + "</a> </li> ");
// How to add components dynamically
// Url. ToolTip = dt. Rows [I] ["newscreatedate"]. ToString ();
// Url. NavigateUrl = navurl + "? Id = "+ dt. Rows [I] [" newsid "]. ToString ();
// Url. Text = dt. Rows [I] ["newstitle"]. ToString ();
// This. Controls. Add (url );
// Add component end
Response. Write ("</li> ");
}
Response. Write ("</ul> ");
}
# Endregion
}
}

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.