如何用asp.net开发wap网站

如何用asp.net开发wap网站,详细点加分!最好是有参考资料!
2025-01-19 03:14:48
推荐回答(1个)
回答1:

给个代码给你看看

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.Data.OleDb;

public partial class viewBook : System.Web.UI.MobileControls.MobilePage
{
public int dxClass;
public int curpage;
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["menuID"] != null)
{
dxClass = Int32.Parse(Request.QueryString["menuID"].ToString());
}

if (!this.IsPostBack)
{
this.Bind();
}

}

//获取目录
private DataSet getMenuDs(int menuID)
{
OleDbConnection con = new OleDbConnection(@"provider=microsoft.jet.oledb.4.0;data source=" + Server.MapPath("App_Data/dx.mdb"));
con.Open();
string strCmd = "select * from menu where from=" + menuID;
OleDbDataAdapter da = new OleDbDataAdapter(strCmd, con);
DataSet ds = new DataSet();
da.Fill(ds);
con.Close();
return ds;
}

//数据绑定
private void Bind()
{
this.List1.Items.Clear();

DataSet menuDs = getMenuDs(dxClass);

this.Label3.Text = Convert.ToString(menuDs.Tables[0].Rows.Count / 10 + 1);

curpage = Int32.Parse(this.Label2.Text);//当前页

//如果当前页是第一页,并且只有一页面,那么不显示按钮
if (this.Label2.Text == this.Label3.Text&&this.Label2.Text=="1")
{
this.Command1.Visible = false;
this.Command2.Visible = false;
}
else if (this.Label2.Text =="1")//如果当前页是第一页,上一页按钮不显示
{
this.Command1.Visible = false;
this.Command2.Visible = true;
}
else if (this.Label2.Text == this.Label3.Text)//当前页是最后一页,那么下一页按钮不显示
{
this.Command1.Visible = true;
this.Command2.Visible = false;
}
else
{
this.Command1.Visible = true;
this.Command2.Visible = true;
}

if (Convert.ToInt32(this.Label2.Text) == Convert.ToInt32(this.Label3.Text))
{
for (int i = (curpage - 1) * 10; i < menuDs.Tables[0].Rows.Count; i++)
{
string dxShort = menuDs.Tables[0].Rows[i]["menuName"].ToString();
MobileListItem item = new MobileListItem(dxShort, "viewList.aspx?bookID=" + menuDs.Tables[0].Rows[i]["menuID"].ToString());
this.List1.Items.Add(item);
}
}
else
{
for (int i = (curpage - 1) * 10; i < curpage * 10 - 1; i++)
{
string dxShort = menuDs.Tables[0].Rows[i]["menuName"].ToString();
MobileListItem item = new MobileListItem(dxShort, "viewList.aspx?bookID=" + menuDs.Tables[0].Rows[i]["menuID"].ToString());
this.List1.Items.Add(item);
}
}

}
//上一页
protected void Command1_Click(object sender, EventArgs e)
{
this.Label2.Text = Convert.ToString(Int32.Parse(this.Label2.Text) - 1);
this.Bind();
}
//下一页
protected void Command2_Click(object sender, EventArgs e)
{
this.Label2.Text = Convert.ToString(Int32.Parse(this.Label2.Text) + 1);
this.Bind();
}
}

1,格式






document title





拨打电话

Call Me Now