使用quickpart部署,还需要将一个swf文件放到wpresources目录下
用户控件cs文件
Code
1 public ArrayList arrTitles = new ArrayList();
2 public ArrayList arrRes = new ArrayList();
3 public ArrayList arrIDs = new ArrayList();
4
5 protected void Page_Load(object sender, EventArgs e)
6 {
7 try
8 {
9 spWeb = SPContext.Current.Web;
10
11 SPList spDataList = spWeb.Lists[ImageList];
12 SPSiteDataQuery myQuery = new SPSiteDataQuery();
13 myQuery.Lists = "<Lists><List ID='" + spDataList.ID.ToString("B").ToUpper() + "'/></Lists>";
14 myQuery.Query = "<OrderBy><FieldRef Name=\"ID\" Ascending=\"False\" /></OrderBy>";
15 DataTable dtPicNews = spWeb.GetSiteData(myQuery);
16
17 if (dtPicNews != null && dtPicNews.Rows.Count > 0)
18 {
19 for (int i = 0; i < dtPicNews.Rows.Count && i < RecorderCount; i++)
20 {
21 SPListItem myItem = spDataList.GetItemById(Convert.ToInt32(dtPicNews.Rows[i]["ID"]));
22 arrTitles.Add(myItem["标题"] != null ? myItem["标题"].ToString() : "图" + (i + 1).ToString());
23 arrIDs.Add(myItem["ID"] != null ? myItem["ID"].ToString() : "");
24 arrRes.Add(myItem["Web 图像 URL"].ToString());
25 }
26 }
27 }
28 catch (Exception ex)
29 { Response.Write(ex.Message); }
30 }
1 public ArrayList arrTitles = new ArrayList();
2 public ArrayList arrRes = new ArrayList();
3 public ArrayList arrIDs = new ArrayList();
4
5 protected void Page_Load(object sender, EventArgs e)
6 {
7 try
8 {
9 spWeb = SPContext.Current.Web;
10
11 SPList spDataList = spWeb.Lists[ImageList];
12 SPSiteDataQuery myQuery = new SPSiteDataQuery();
13 myQuery.Lists = "<Lists><List ID='" + spDataList.ID.ToString("B").ToUpper() + "'/></Lists>";
14 myQuery.Query = "<OrderBy><FieldRef Name=\"ID\" Ascending=\"False\" /></OrderBy>";
15 DataTable dtPicNews = spWeb.GetSiteData(myQuery);
16
17 if (dtPicNews != null && dtPicNews.Rows.Count > 0)
18 {
19 for (int i = 0; i < dtPicNews.Rows.Count && i < RecorderCount; i++)
20 {
21 SPListItem myItem = spDataList.GetItemById(Convert.ToInt32(dtPicNews.Rows[i]["ID"]));
22 arrTitles.Add(myItem["标题"] != null ? myItem["标题"].ToString() : "图" + (i + 1).ToString());
23 arrIDs.Add(myItem["ID"] != null ? myItem["ID"].ToString() : "");
24 arrRes.Add(myItem["Web 图像 URL"].ToString());
25 }
26 }
27 }
28 catch (Exception ex)
29 { Response.Write(ex.Message); }
30 }
前台代码
Code
1<div>
2<script language="javascript" type="text/javascript">
3 imgUrl = new Array();
4 imgText = new Array();
5 imgLink = new Array();
6
7 var pics = "";
8 var links = "";
9 var texts = "";
10
11 if("<%= arrRes %>" != null && "<%= arrRes.Count %>" > 0){
12 <%for(int m=0; m<arrRes.Count; m++){ %>
13 imgUrl[<%= m %>] = "<%= arrRes[m] %>";
14 imgText[<%= m %>] = "<%= arrTitles[m] %>";
15 imgLink[<%= m %>] = "<%= Page.ResolveClientUrl(arrRes[m].ToString().Replace("/_w/","@").Split('@')[0]+"/Forms/DispForm.aspx?ID=" + arrIDs[m]) %>";
16
17 if("<%= m %>" < "<%= arrRes.Count %>" - 1)
18 {
19 pics += imgUrl[<%= m %>]+"|";
20 links += imgLink[<%= m %>]+"|";
21 texts += imgText[<%= m %>]+"|";
22 }
23 else
24 {
25 pics += imgUrl[<%= m %>];
26 links += imgLink[<%= m %>];
27 texts += imgText[<%= m %>];
28 }
29 <%}%>
30 }
31 var focus_width=276
32 var focus_height=200
33 var text_height=18
34 var swf_height = focus_height+text_height
35
36 document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ focus_width +'" height="'+ swf_height +'">');
37 document.write('<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="<%=Page.ResolveClientUrl("/wpresources/focus2.swf") %>"><param name="quality" value="high"><param name="bgcolor" value="#fff">');
38 document.write('<param name="menu" value="false"><param name="wmode" value="opaque">');
39 document.write('<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'">');
40 document.write('</object>');
41</script>
42</div>
43
44
1<div>
2<script language="javascript" type="text/javascript">
3 imgUrl = new Array();
4 imgText = new Array();
5 imgLink = new Array();
6
7 var pics = "";
8 var links = "";
9 var texts = "";
10
11 if("<%= arrRes %>" != null && "<%= arrRes.Count %>" > 0){
12 <%for(int m=0; m<arrRes.Count; m++){ %>
13 imgUrl[<%= m %>] = "<%= arrRes[m] %>";
14 imgText[<%= m %>] = "<%= arrTitles[m] %>";
15 imgLink[<%= m %>] = "<%= Page.ResolveClientUrl(arrRes[m].ToString().Replace("/_w/","@").Split('@')[0]+"/Forms/DispForm.aspx?ID=" + arrIDs[m]) %>";
16
17 if("<%= m %>" < "<%= arrRes.Count %>" - 1)
18 {
19 pics += imgUrl[<%= m %>]+"|";
20 links += imgLink[<%= m %>]+"|";
21 texts += imgText[<%= m %>]+"|";
22 }
23 else
24 {
25 pics += imgUrl[<%= m %>];
26 links += imgLink[<%= m %>];
27 texts += imgText[<%= m %>];
28 }
29 <%}%>
30 }
31 var focus_width=276
32 var focus_height=200
33 var text_height=18
34 var swf_height = focus_height+text_height
35
36 document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ focus_width +'" height="'+ swf_height +'">');
37 document.write('<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="<%=Page.ResolveClientUrl("/wpresources/focus2.swf") %>"><param name="quality" value="high"><param name="bgcolor" value="#fff">');
38 document.write('<param name="menu" value="false"><param name="wmode" value="opaque">');
39 document.write('<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'">');
40 document.write('</object>');
41</script>
42</div>
43
44