dojo 随手记[GridContainer]
图片管理页面。
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<link type="text/css" rel="stylesheet" href="../dojos/dojox/widget/Portlet/Portlet.css" />
<link rel="stylesheet" href="../dojos/dojox/layout/resources/GridContainer.css" />
<link rel="stylesheet" href="../dojos/dojox/layout/resources/DndGridContainer.css" />
<script type="text/javascript" src="uieditpage.js"></script>
<script type="text/javascript">
dojo.require("dijit.layout.ContentPane");
dojo.require("dojox.layout.GridContainer");
dojo.require("dojox.widget.Portlet");
dojo.require("dojox.widget.PortletSettings");
function setshowinlist(flows) {
if (!flows) {
return;
}
var imagemanagerstruct = {
flowno: flows.substring(1),
relationtype: '<%=Request["imagetype"] %>',
shopid: '<%=Request["shopid"] ?? ""%>',
branchno: '<%=Request["branchno"] ?? ""%>'
};
var xhrArgs = {
url: '<%=ResolveUrl("~/uieditserver.ashx") %>' + "?operation=image_manager.SetMain",
handleAs: "json",
content: {
dojojsondata: dojo.toJson(imagemanagerstruct)
},
load: function (data) {
if (data.ErrorNo == 0) {
window.location.reload();
}
else {
alert(data.ErrorInfo);
}
},
error: function (error) {
alert(error);
return;
}
}
// Call the asynchronous xhrGet
var deferred = dojo.xhrGet(xhrArgs);
return true;
}
function imageuploadfinised(data) {
if (data.ErrorNo > 0) {
alert(data.ErrorInfo || '未知错误');
}
else {
window.location.reload();
}
}
function deleteimage(flows) {
if (!flows) {
return;
}
if (!confirm("是否删除此图片")) {
return false;
}
var xhrArgs = {
url: '<%=ResolveUrl("~/uieditserver.ashx") %>' + "?operation=image_managerList.DeleteAll",
handleAs: "json",
content: {
key: flows.substring(1)
},
load: function (data) {
if (data.ErrorNo == 0) {
if (toaster)
toaster.showinfo("删除成功");
var getdelete = dijit.byId("p" + flows.substring(1));
if (getdelete)
getdelete.destroy();
//window.location.reload();
}
else {
alert(data.ErrorInfo);
}
},
error: function (error) {
alert(error);
return;
}
}
// Call the asynchronous xhrGet
var deferred = dojo.xhrGet(xhrArgs);
return true;
}
</script>
<style type="text/css">
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div data-dojo-type="dijit/form/Form" id="myForm" data-dojo-id="myForm"
enctype="multipart/form-data" action="" method="">
<div id="toolbar1" data-dojo-type="dijit/Toolbar">
<input type="file" data-dojo-type="dojox/form/Uploader"
data-dojo-props="multiple:false, url:'uploadimg.aspx?imgtype=<%=Request["imagetype"] ??"" %>&relationname=<%=Request["imagekey"] ?? "" %>&shopid=<%=Request["shopid"] ?? "" %>&branchno=<%=Request["branchno"] ?? "" %>',uploadOnSelect:true,iconClass:'dijitIconFolderOpen', showLabel:true,
onComplete:function(data){
imageuploadfinised(data);
},label:'请选择图片上传'" />
</div>
<div dojotype="dojox.layout.GridContainer"
nbzones="4"
hasresizablecolumns="false"
dolayout="false">
<%
var imagetype = Request["imagetype"] ?? "";
var imagekey = Request["imagekey"] ?? "";
var imagebranchno = Request["branchno"] ?? "";
WH.CSLA.Utilities.ICriteria<YHWebCore.Business.image_manager> criteria = WH.CSLA.Utilities.CriteriaFactory.Create<YHWebCore.Business.image_manager>();
var wherecriteria = criteria.Where(q => q.branchno == imagebranchno
&& q.relationtype == imagetype
&& q.relationname == imagekey);
var imagemanagers = YHWebCore.Business.image_managerList.Fetch(wherecriteria);
foreach (var item in imagemanagers)
{%>
<div data-dojo-type="dijit/layout/ContentPane" id="p<%=item.flowno %>">
<div id="sontoolbar<%=item.flowno %>" data-dojo-type="dijit/Toolbar">
<%if (!item.listflag)
{ %>
<div data-dojo-type="dijit/form/Button" id="l<%=item.flowno %>"
data-dojo-props="iconClass:'dijitIconTable', showLabel:true,onClick:function(){setshowinlist(this.id); }">
显示在列表中
</div>
<%} %>
<div data-dojo-type="dijit/form/Button" id="d<%=item.flowno %>"
data-dojo-props="iconClass:'dijitIconTable', showLabel:true,onClick:function(){deleteimage(this.id); }">
删除
</div>
</div>
<div>
<img src="<%=item.imageurl %>" style="width:200px;height:124px;" />
</div>
</div>
<%}
%>
</div>
</div>
</asp:Content>