首页 Asp.net 格子网制作代码

Asp.net 格子网制作代码

举报
开通vip

Asp.net 格子网制作代码Asp.net 格子网制作代码 using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using ...

Asp.net 格子网制作代码
Asp.net 格子网制作代码 using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.OleDb; using System.IO; public partial class WebUserControl : System.Web.UI.UserControl { delegate void ClientClick(string str); protected void Page_Load(object sender, EventArgs e) { CreateTable(); string unit = "px"; string strconn = ConnManager.Data_Conn().ToString(); OleDbConnection conn = new OleDbConnection(strconn); OleDbCommand Ad = new OleDbCommand("select * from View_Grid", conn); conn.Open(); OleDbDataReader read = Ad.ExecuteReader(); while (read.Read()) { int x = Convert.ToInt32(read["x"].ToString()); //横排第几格 int y = Convert.ToInt32(read["y"].ToString()); //竖排第几格 int number_x = Convert.ToInt32(read["number_x"].ToString()); //横排占 几格 int number_y = Convert.ToInt32(read["number_y"].ToString()); //竖排 占几格 string width = Convert.ToString(100 * number_x).ToString(); string height = Convert.ToString(100 * number_y).ToString(); string left = Convert.ToString((x - 1) * 100) + unit; string top = Convert.ToString((y - 1) * 100) + unit; string bottom = height + unit; string right = width + unit; ImageMap map = new ImageMap(); map.DescriptionUrl = read["Dealer_ID"].ToString(); map.ToolTip = read["Dealer_DoMainName"].ToString(); map.ImageUrl = read["images"].ToString(); FileInfo file = new FileInfo(Server.MapPath(read["images"].ToString())); if (!file.Exists) { map.BackColor = System.Drawing.Color.Red; string top1 = Convert.ToString((y - 1) * 100+30) + unit; string left1 = Convert.ToString((x - 1) * 100+10) + unit; CreateLinkButton(read["Dealer_ID"].ToString(), read["title"].ToString(), read["Dealer_DoMainName"].ToString(), right, bottom, left1, top1); } MapAtribue(map); MapStyle(map); this.SetStyle(map.Style, right, bottom, left, top); map.Click += new ImageMapEventHandler(ImageMap1_Click); this.Controls.Add(map); RHS(map, 100 * number_x, 100 * number_y, map.ToolTip); } conn.Close(); } /// /// 添加ImageMpa信息 /// /// /// /// /// protected void RHS(ImageMap map, int right, int bottom, string tooltip) { RectangleHotSpot re = new RectangleHotSpot(); re.Left = 0; re.Right = right; re.Bottom = bottom; re.Top = 0; re.PostBackValue = "Client"; re.Target = "_blank"; re.HotSpotMode = HotSpotMode.PostBack; re.NavigateUrl = tooltip; re.AlternateText = tooltip; map.HotSpots.Add((HotSpot)re); } /// /// 设置ImageMap属性 /// /// protected void MapAtribue(ImageMap map) { map.HotSpotMode = HotSpotMode.PostBack; map.ImageAlign = ImageAlign.AbsMiddle; } /// /// 设置ImageMap样式 /// /// protected void MapStyle(ImageMap map) { Style Style = new Style(); Style.CssClass = "image"; map.ApplyStyle(Style); } /// /// 设置ImageMap样式 /// /// /// /// /// /// private void SetStyle(CssStyleCollection style, string width, string height, string left, string top) { style.Add("width", width); style.Add("height", height); style.Add("margin-left", left); style.Add("margin-top", top); } /// /// ImageMap1单击事件 /// /// /// protected void ImageMap1_Click(object sender, ImageMapEventArgs e) { ImageMap im = (ImageMap)(sender); int id = Convert.ToInt32(im.DescriptionUrl.ToString()); UpdateClick(id); } /// /// 创建LinkButton /// /// /// /// /// /// /// protected void CreateLinkButton(string id, string text, string right,string tooltip, string bottom, string left, string top) { LinkButton link = new LinkButton(); link.ID = id.ToString(); link.Text = text; link.ToolTip = tooltip; if (link.Text.Length > 20) { link.Text = link.Text.Substring(0, 18) + "..."; } Style Style = new Style(); Style.CssClass = "linkbutton1"; link.Height = 25; link.Width = 80; link.ApplyStyle(Style); this.LinkStyle(link.Style, left, top); link.Attributes.Add("onMouseOver", "this.style.color='Blue';this.style.cursor='hand';this.style.font='normal small-caps bold 10pt serif';"); link.Attributes.Add("onMouseOut", "this.style.color='DarkBlue';this.style.font='normal small-caps normal 9pt serif';"); link.Click += new EventHandler(link_Click); this.Controls.Add(link); } /// /// 设置LinkButton样式 /// /// private void LinkStyle(CssStyleCollection style,string left, string top) { style.Add("margin-left", left); style.Add("margin-top", top); } /// /// LinkButton单击事件 /// /// /// protected void link_Click(object sender, EventArgs e) { LinkButton link = (LinkButton)(sender); int id = Convert.ToInt32(link.ID.ToString()); UpdateClick(id); } /// /// 更新信息 /// /// protected void UpdateClick(int id) { string select = "select * from View_Grid where Dealer_ID=" + id + ""; DataTable table = Data_Manager.ExecuteDataSet(select, "view_grid").Tables[0]; int Dealer_Clickcount = Convert.ToInt32(table.Rows[0]["Dealer_Clickcount"].ToString()) + 1; string update = "update Tb_DealerInfo set Dealer_Clickcount=" + Dealer_Clickcount + " where Dealer_ID=" + id + ""; Data_Manager.ExecuteNonQuery(update); string path = table.Rows[0]["Dealer_DoMainName"].ToString(); if (path == "http:/" + "/" || path == "" || table.Rows[0]["IsLogin"].ToString() == "True") { Session["Userid"] = id.ToString(); Response.Redirect("Index.aspx?userid=" + Session["Userid"].ToString() + ""); } else { Response.Redirect(path, true); } } /// /// 创建Table框架 /// protected void CreateTable() { int j = 1; Style tablestyle = new Style(); tablestyle.CssClass = "table"; Style style2 = new Style(); style2.CssClass = "row"; Style style = new Style(); style.CssClass = "Cell"; Table table = new Table(); table.ApplyStyle(style2); table.Width = 1000; table.Height = 1000; table.BackColor = System.Drawing.Color.White; Random rad1 = new Random(); for (int row = 0; row < 1000; row += 100) { TableRow tablerow = new TableRow(); tablerow.Height = 100; int i = 1; Random rad2 = new Random(); for (int cell = 0; cell < 1000; cell += 100) { Random rad = new Random(); TableCell tablecell = new TableCell(); tablecell.ToolTip = "行:" + j + " 列:" + i + "" + "(" + row + "px," + cell + "px)"; tablecell.Width = 100; tablecell.Height = 100; tablecell.BorderWidth = 1; tablecell.Attributes.Add("onMouseOver", "this.style.backgroundColor='#e9e9e9';this.style.cursor='hand';"); tablecell.Attributes.Add("onMouseOut", "this.style.backgroundColor='#FFFFFF'"); tablerow.Cells.Add(tablecell); i++; } j++; tablerow.BorderWidth = 1; table.Rows.Add(tablerow); } this.Controls.Add(table); } }
本文档为【Asp&#46;net 格子网制作代码】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_682974
暂无简介~
格式:doc
大小:32KB
软件:Word
页数:0
分类:互联网
上传时间:2018-11-10
浏览量:4