When designing WAP in ASP.net, I found that there was no ImageList control and I had to design it myself. The Image and LINK controls are mainly used during design. I made a user control PicList. ascx. The interface is as follows:
The Panel control is used at the top to display the image list. The "Previous Page" and "next page" are shown below, and you can select a page.
--Wap.joymo.cn
The Code is as follows:
Using System;
Using System. Collections;
Using System. ComponentModel;
Using System. Data;
Using System. Drawing;
Using System. Web;
Using System. Web. Mobile;
Using System. Web. SessionState;
Using System. Web. UI;
Using System. Web. UI. MobileControls;
Using System. Web. UI. WebControls;
Using System. Web. UI. HtmlControls;
Using System. Configuration;
// Content from wap.joymo.cn
// Author: freemobile
Namespace joymo
{
Public partial class usercontrol_PicList: System. Web. UI. MobileControls. MobileUserControl
{
Public DataTable PicData; // value assigned by the page that calls the control
Private int _ pageSize = 0;
Private int _ pageCount = 0;
Protected void Page_Load (object sender, EventArgs e)
{
If (! IsPostBack & PicData! = Null)
{
Try
{
GetSelectPage (Math. Abs (Convert. ToInt32 (Request. QueryString ["page"]);
}
Catch (Exception ex)
{}
}
}
// Display the page with the corresponding page number -- wap.joymo.cn
Protected void GetSelectPage (int page)
{
_ PageSize = Convert. ToInt32 (ConfigurationManager. receivettings ["PicPageSize"]); // number of entries per page
If (PicData! = Null & PicData. Rows. Count> 0)
{
Int itemCount = PicData. Rows. Count;
_ PageCount = 0;
If (itemCount % _ pageSize! = 0)
_ PageCount = itemCount/_ pageSize + 1;
Else
_ PageCount = itemCount/_ pageSize;
Int startID = page * _ pageSize;
If (startID> = itemCount)
StartID = (_ pageCount-1) * _ pageSize;
Int endID = startID + _ pageSize;
For (int I = startID; I <(itemCount> endID? EndID: itemCount); I ++)
{
System. Web. UI. MobileControls. Image img = new System. Web. UI. MobileControls. Image ();
Img. ImageUrl = (string) PicData. Rows [I] [0]; // thumbnail
Img. NavigateUrl = (string) PicData. Rows [I] [1]; // Actual Image Location
Img. BreakAfter = false;
Panel1.Controls. Add (img );
Link linkMemo = new Link ();
LinkMemo. Text = (string) PicData. Rows [I] [2]; // picture description
LinkMemo. NavigateUrl = (string) PicData. Rows [I] [1];
Panel1.Controls. Add (linkMemo );
}
If (page = 0)
{
LinkPre. NavigateUrl = Page. Request. FilePath + "? Page = 0 "; //" Previous page "Link
LinkNext. NavigateUrl = Page. Request. FilePath + "? Page = 0 "; //" next page "Link
}
Else
{
LinkPre. NavigateUrl = Page. Request. FilePath + "? Page = "+ (page-1 );
LinkNext. NavigateUrl = Page. Request. FilePath + "? Page = "+ (page + 1 );
}
LabPage. Text = "Total" + _ pageCount + "page-> page" + (page + 1) + "page ";
}
}
Protected void upload go_click (object sender, EventArgs e)
{
Try
{
(MobilePage) Page). RedirectToMobilePage (Request. FilePath + "? Page = "+ Math. Abs (Convert. ToInt32 (TextBox1.Text)-1 ));
}
Catch (Exception ex)
{}
}
}
}
The final execution result is as follows: