1.将时间转换成STRING格式:
model.opentime = Utils.ObjectToDateTime(txtaddtime.Text);
赋值时间
txtaddtime.Text = Convert.ToDateTime(model.addtime).ToString("yyyy-MM-dd HH:mm:ss");
发布日期:<%=model!=null?Convert.ToDateTime(model.addtime).ToString("yyyy-MM-dd HH:mm:ss"):"" %>(页面绑定时间)
循环年月日<%#Eval("addtime","{0:yyyy}") %>-<%#Eval("addtime","{0:MM}") %>-<%#Eval("addtime","{0:dd}") %>
时间去掉秒<td align="center"><%#string.Format("{0:g}", Eval("addtime"))%></td>
2.A标签提示内容
<a onclick="alert('提示内容')">内容</a>
3.绑定数据时把后台时间数据绑定格式
<%=Convert.ToDateTime(model.addtime).ToString("yyyy-MM-dd") %>
4.循环图片大小不同索引进行绑定
protected List<ht_environment> clist;
var list = db.ht_environment.Where(x => x.id > 0).OrderBy(x => x.sort).Take(4).ToList();
clist = list;(后台)
<li><img src="<%=clist[0].img_url %>" alt="" /></li>
<li><img src="<%=clist[1].img_url %>" alt="" /></li>(前台)
5.about_edit(前台)按分类查询(x=>x.type==1)
<dl>
<dt>类型</dt>
<dd>
<div class="rule-multi-radio">
<asp:RadioButtonList ID="rdoType" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow">
<asp:ListItem Value="1" Selected="True">服务优势</asp:ListItem>
<asp:ListItem Value="2">旗下机构</asp:ListItem>
</asp:RadioButtonList>
</div>
</dd></dl>
rdoType.SelectedValue = model.type.ToString();(后台赋值操作)
model.type =Convert.ToInt32(rdoType.SelectedValue);(后台增加操作)
6.内容摘要提取内容前120个字符
model.zhaiyao = !string.IsNullOrEmpty(description) ? description : temp.Length > 200 ? temp.Substring(0, 200) : temp;
//内容摘要提取内容前120个字符
if (string.IsNullOrEmpty(txtzhaiyao.Text.Trim()))
{
model.zhaiyao = Utils.DropHTML(txtContent.Value, 200);
}
else
{
model.zhaiyao = Utils.DropHTML(txtzhaiyao.Text, 200);
}
7.把超链图片下载到本地服务器
model.center = new HT.Web.UI.AdminBllPage().GetContentImgUpload(model.center.Trim());
8.清除文本中的空格
model.zhaiyao=txtzhaiyao.Text.Trim();
9.通过点击获取的ID进行更改样式
<li class="<%#Eval("id").ToString()==id.ToString()?"act":"" %>"><a href="Project-<%#Eval("id")%>.html">
<span><%#Eval("title") %></span>
</a>
</li>
10.获取type的对应标题
public string GetTypeTitle(int type)
{
string title = "";
switch (type)
{
case 1:
title = "校友服务中心";
break;
case 2:
title = "活动预告";
break;
case 3:
title = "活动报道";
break;
}
return title;
}(后台写方法)(三个type分类)
<a href="###"><%=new HT.Web.UI.WebBllPage().GetTypeTitle(type) %></a>(前台获取方法后获取title)
<h4><%=model2!=null?(new HT.Web.UI.WebBllPage().GetTypenum(Convert.ToInt32(model2.num))):"" %></h4>
11.protected EntitiesModel db = new EntitiesModel();
12._edit.aspx页面里添加id分类的下拉框形式,根据分类添加数据
<dl>
<dt>下载分类</dt>
<dd>
<div class="menu-list">
<div class="rule-single-select">
<asp:DropDownList ID="ddlcategory" runat="server"></asp:DropDownList>
</div>
</div>
</dd>
</dl>(前页)
model.category_id = Convert.ToInt32(ddlcategory.SelectedValue);(增修)
ddlcategory.SelectedValue = model.category_id.ToString();(赋值)
#region 绑定类型=============================
private void CategoryBind()
{
var list = db.ht_download_category.Where(x => x.id > 0);
ddlcategory.Items.Clear();
ddlcategory.Items.Add(new ListItem("请选择", ""));
foreach (var item in list)
{
ddlcategory.Items.Add(new ListItem(item.title, item.id.ToString()));
}
}(以及绑定数据类型)
13.在Repeater循环中查询出当前的天或月
<%#Eval("addtime","{0:yyyy-MM-dd}") %>
<%=Convert.ToDateTime(model.addtime).ToString("yyyy-MM-dd") %>
14.在下拉框中选择下拉框的内容进行跳转
<%--这个是页面直接跳转--%>
<%-- <select onchange="window.location.href=this.options[selectedIndex].value" >--%>
<%--下面的这个是在新窗口中打开--%>
<select onchange="window.open(this.options[selectedIndex].value)" >
<option value="http://www.baidu.com">Select a Language2</option>
<option value="http://www.baidu.com">Select a Language3</option>
</select>
15.如果model 那么跳转是列表页
if (model == null)
{
Response.Redirect("WineCulture.html");
}
16.调用方法里面TITLE名
<dd>产地:<%#new HT.Web.UI.WebBllPage().GetTypeTitle(Convert.ToInt32(Eval("where")))%></dd>
17.建表
create table ht_capacity
(
id int primary key identity(1,1)NOT NULL,
title [nvarchar](250) NULL,
types int NULL,
img_url [nvarchar](250) NULL,
sort [int] NULL,
)
18.后台里的CheckBoxList的多选
<dl>
<dt>类别</dt>
<dd>
<div class="rule-multi-porp">
<asp:CheckBoxList ID="cblcategoryList" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow"></asp:CheckBoxList>
</div>
</dd>
</dl>
#region 绑定类别=================================
private void TreeBind()
{
var list = db.ht_product_category.Where(x => x.id > 0);
cblcategoryList.Items.Clear();
cblcategoryList.Items.Add(new ListItem("请选择", ""));
foreach (var item in list)
{
cblcategoryList.Items.Add(new ListItem(item.title, item.id.ToString()));
}
}
#endregion
cblcategoryList.SelectedValue = model.category_id.ToString();
model.category_id = Convert.ToInt32(cblcategoryList.SelectedValue);
20.Repeater包含又一个Repeater
<asp:Repeater ID="showlist" runat="server" OnItemDataBound="rptcategory_ItemDataBound">
<ItemTemplate>
<asp:Label runat="server" Text='<%#Eval("id")%>' ID="lbcid" Visible="False"></asp:Label>
<div class="title about_title">
<div class="H40"></div>
<h5>私人订制</h5>
<p>PERSONAL TAILOR</p>
<span style="font-size: 18px;"><%#Eval("title") %></span>
<div class="H30"></div>
</div>
<div class="arrang_list box">
<ul>
<asp:Repeater ID="allist" runat="server">
<ItemTemplate>
<li><a href="./garden-<%#Eval("id") %>.html">
<img src="<%#Eval("img_url") %>" alt=""></a></li>
</ItemTemplate>
</asp:Repeater>
</ul>
</div>
</ItemTemplate>
</asp:Repeater>
后台
protected void Bind()
{
showlist.DataSource = db.ht_works_category.Where(x => x.id > 0 && x.type == 1).OrderBy(x => x.sort).ThenByDescending(x => x.id).ToList();
showlist.DataBind();
}
protected void rptcategory_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
//绑定商品
Label lbcid = (Label)e.Item.FindControl("lbcid");
Repeater rptlist = (Repeater)e.Item.FindControl("allist");
int cid = Convert.ToInt32(lbcid.Text);
var list = db.ht_works.Where(x => x.id > 0 && x.category_id == cid && x.img_url != "");
list = list.OrderBy(x => x.sort).ThenByDescending(x => x.id);
rptlist.DataSource = list.ToList();
rptlist.DataBind();
}
22.根据一张在的关联信息查询另一张表 category_id => id
顶部需要加<%@ Import Namespace="HT.Common" %>
<%#new HT.Web.UI.WebBllPage().GetImgCateTitle(Utils.ObjToInt(Eval("where"),0)) %>
(外部填写方法) public string GetImgCateTitle(int where)
{
string title = db.ht_product_where.Where(x => x.id==where).Select(x => x.title).FirstOrDefault();
if (string.IsNullOrEmpty(title)) { return "-"; }
return title;
}
<%=model!=null?(new HT.Web.UI.WebBllPage().GetImgCateYears(Utils.ObjToInt(model.years))):"" %>
(外部填写方法) public string GetImgCateYears(int years)
{
string title = db.ht_product_years.Where(x => x.id == years).Select(x => x.title).FirstOrDefault();
if (string.IsNullOrEmpty(title)) { return "-"; }
return title;
}
23.截取长度
<%#Eval("content").ToString().Length>30?Eval("content").ToString().Substring(0,30)+"...":Eval("content") %>
或
<%#HT.Common.Utils.CutString(Eval("title").ToString(),20) %>
24.根据隔表绑定数据
var er_list = db.ht_all.Where(x => x.id > 0 && x.category_id == id).OrderBy(x => x.sort).ToList();
List<ht_all_list> product_list = new List<ht_all_list>();
foreach (var item in er_list)
{
var all_list = db.ht_all_list.Where(x => x.id > 0 && x.all_list == item.id).OrderBy(x => x.sort);
foreach (var i in all_list)
{
product_list.Add(i);
}
}
modellist.DataSource = product_list;
modellist.DataBind();
25._list页面文字样式
<td align="center">
<%#Convert.ToInt32(Eval("run")) ==1?"否":"<font style='color:red;'>是</font>"%>
</td>
26.进入页面时没有ID时自动获取第一条ID(后台代码)
var list = db.ht_advantages.Where(x => x.id > 0).OrderBy(x => x.id).ToList();
if (id == 0 && list.Count > 0)
{
id = list[0].id;
}
model = db.ht_advantages.Where(x => x.id == id).FirstOrDefault();
27.索引repeter循环里面自动增长
<%#Container.ItemIndex+1%>
(1>2>3.......)
28让数据库删除数据后的ID又从1开始自增
dbcc checkident('ht_news',reseed,0)
29.后台上传图片限制宽高
$(".upload-img5").InitUploader({ widthhegiht: "600*202", sendurl: "../../tools/upload_ajax.ashx", swf: "../../scripts/webuploader/uploader.swf" });
30.内容摘要提取内容前120个字符
string description = txtzhaiyao.Text;
model.zhaiyao = !string.IsNullOrEmpty(description) ? description : temp.Length > 200 ? temp.Substring(0, 200) : temp;
//内容摘要提取内容前120个字符
if (string.IsNullOrEmpty(txtzhaiyao.Text.Trim()))
{
model.zhaiyao = Utils.DropHTML(txtContent.Value, 200);
}
else
{
model.zhaiyao = Utils.DropHTML(txtzhaiyao.Text, 200);
}
31.后台SEO信息未填写则自动读取
model.seo_title = txtseotitle.Text;
model.seo_keywords = txtseokeys.Text;
model.seo_description = txtseodesc.Text;
if (string.IsNullOrEmpty(model.seo_title.Trim()))
{
model.seo_title = model.title;
}
if (string.IsNullOrEmpty(model.seo_keywords.Trim()))
{
model.seo_keywords = model.abstracts;
}
if (string.IsNullOrEmpty(model.seo_description.Trim()))
{
model.seo_description = Utils.DropHTML(this.txtContent.Value, 200);
}
32.检测是否在手机端打开电脑网页时跳转另一个页面
<script type="text/javascript">
//平台、设备和操作系统
var system = {
win: false,
mac: false,
xll: false
};
//检测平台
var p = navigator.platform;
// alert(p);
system.win = p.indexOf("Win") == 0;
system.mac = p.indexOf("Mac") == 0;
system.x11 = (p == "X11") || (p.indexOf("Linux") == 0);
//跳转语句
if (system.win || system.mac || system.xll) {
//
} else {
window.location.href = "http://m.wenfengedu.cn/";
}
</script>
33.页面头部的动态样式
header后台 public string locheader { get; set; }
header前台 class="<%=locheader=="首页"?"active":"" %>"
34.标题包含某字段
title.Contains(keywords)
35.循环里面没有数据的时候显示暂无数据
<%=newlist.Items.Count==0?"<div style='width:100%; line-height:350px; text-align:center; color:#999'>暂无数据</div>":"" %>
36.页面banner图绑定
<%=new HT.Web.UI.BasePage().GetBaListHtml("index_roll","<li><a href=\"{1}\"><img src=\"{0}\"/></a></li>",2)%>
37.script验证正则
if (!txtmobile.match(/^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/)) {
layer.msg('对不起,手机格式不正确,请输入正确的手机', { icon: 2, shift: 6 });
return;
}
if (!txtemail.match(/^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/)) {
layer.msg('请输入正确的邮箱', { icon: 2, shift: 6 });
return;
}
//验证是否为空
if (txtcontent == "") {
layer.msg('对不起:留言内容不能为空!', { icon: 2, shift: 6 });
return;
}
38.先验证手机号是否为空,再验证是否正确
if (string.IsNullOrEmpty(txtmobile))
{
/返回URL
context.Response.Write("{\"status\":0, \"msg\":\"请填写手机再提交!\"}");
return;
}
var flag = false;
Regex r = new Regex("/^13[0-9]{9}$|14[0-9]{9}|15[0-9]{9}$|17[0-9]{9}$|18[0-9]{9}$/");
//验证手机
if (r.IsMatch(txtmobile))
{
flag = true;
}
if (!flag)
{
context.Response.Write("{\"status\":0, \"msg\":\"对不起 , 手机格式不正确!\"}");
return;
}
39.初次加载时获取ID
var list = db.ht_server_category.Where(x => x.id > 0).OrderBy(x => x.sort).ToList();
if (id == 0)
{
id = list[0].id;
}
model = db.ht_server_category.Where(x => x.id == id).FirstOrDefault();
或者
var slist = db.ht_enterpriseshow_category.Where(x => x.parent_id == parent_id).OrderBy(x => x.sort).ToList();
if (slist.Count > 0)
{
this.id = (this.id == 0) ? slist[0].id : this.id;
}
40._list里面的推荐
<td align="center">
<div class="btn-tools">
<asp:LinkButton ID="lbtnIsRed" CommandName="lbtnIsRed" runat="server" CssClass='<%# Convert.ToInt32(Eval("is_red")) == 2 ? "red selected" : "red"%>' ToolTip='<%# Convert.ToInt32(Eval("is_red")) == 1 ? "取消推荐" : "设置推荐"%>' />
</div>
</td>
41.reperte循环里
<%#Container.ItemIndex==4?"member-product.html":"project-cooperation-"+Eval("id") +".html" %>
循环中的前4条数据跳转第一个链接,后4个数据跳转第二个链接
42.详情页里获取分类ID
cid = db.ht_news_category.Where(x => x.id == model.category).FirstOrDefault().id;
43.后台checkbox的使用
(edit前台的审核)
<dl>
<dt>文章审核</dt>
<dd>
<div class="rule-single-checkbox">
<asp:CheckBox ID="txtsalt" runat="server" />
</div>
<span class="Validform_checktip">*是否通过,未通过将无法显示</span>
</dd>
</dl>
(后台默认不选中或手动选中)
修增
if (txtsalt.Checked )
{
model.salt = 2;
}
else
{
model.salt = 1;
}
赋值
if (model.salt == 1)
{
txtsalt.Checked = false;
}
else
{
txtsalt.Checked = true;
}
44.获取下拉框的值并跳转页面
<script>
function onhref() {
location.href = "party-affairs-expenditure.aspx?id=" + $("#pname").val();
}
</script>
<select name="pname" id="pname" onchange="onhref()">
<asp:Repeater ID="yearlist" runat="server">
<ItemTemplate>
<option <%#Eval("id").ToString()==id.ToString()?"selected=\"selected\"":""%> value="<%#Eval("id") %>"><%#Eval("title") %></option>
</ItemTemplate>
</asp:Repeater>
</select>
45.批量上传
$(function(){
$(".upload-album").InitUploader({ btntext: "批量上传", multiple: true, thumbnail: true, filesize: "<%=siteConfig.imgsize %>", sendurl: "../../tools/upload_ajax.ashx", swf: "../../scripts/webuploader/uploader.swf" });
});
<dl id="div_albums_container" runat="server">
<dt>批量上传</dt>
<dd>
<div class="upload-box upload-album"></div>
<input type="hidden" name="hidFocusPhoto" id="hidFocusPhoto" runat="server" class="focus-photo" /><span class="Validform_checktip">284*172 请严格根据分辨上传图片</span>
<div class="photo-list">
<ul>
<asp:Repeater ID="rptAlbumList" runat="server">
<ItemTemplate>
<li>
<input type="hidden" name="hid_photo_name" value="<%#Eval("id")%>|<%#Eval("original_path")%>|<%#Eval("thumb_path")%>" />
<input type="hidden" name="hid_photo_remark" value="<%#Eval("remark")%>" />
<div class="img-box" onclick="setFocusImg(this);">
<img src="<%#Eval("thumb_path")%>" bigsrc="<%#Eval("original_path")%>" />
<span class="remark"><i><%#Eval("remark") == null ? "暂无描述..." : Eval("remark").ToString()%></i></span>
</div>
<a href="javascript:;" onclick="setRemark(this);">描述</a>
<a href="javascript:;" onclick="delImg(this);">删除</a>
</li>
</ItemTemplate>
</asp:Repeater>
</ul>
</div>
</dd>
</dl>
赋值操作=================================
#region 图片相册
rptAlbumList.DataSource = db.ht_img.Where(s => s.obj_id == _id).ToList(); ;
rptAlbumList.DataBind();
#endregion
增加操作=================================
if (db.SaveChanges() > 0)
{
#region 保存相册====================
string[] albumArr = Request.Form.GetValues("hid_photo_name");//图片路径数组
string[] remarkArr = Request.Form.GetValues("hid_photo_remark"); //备注数组
if (albumArr != null && albumArr.Length > 0)
{
for (int i = 0; i < albumArr.Length; i++)
{
string[] imgArr = albumArr[i].Split('|');
if (imgArr.Length == 3)
{
ht_img mo = new ht_img();
if (string.IsNullOrEmpty(remarkArr[i]))
{
mo.original_path = imgArr[1];
mo.thumb_path = imgArr[2];
}
else
{
mo.original_path = imgArr[1];
mo.thumb_path = imgArr[2];
mo.remark = remarkArr[i];
}
mo.obj_id = model.id;
mo.add_time = DateTime.Now;
db.ht_img.Add(mo);
db.SaveChanges();
}
}
}
#endregion
return true;
}
return false;
修改操作================================
#region 保存相册 滚动图==============
string[] albumArr1 = Request.Form.GetValues("hid_photo_name");
string[] remarkArr1 = Request.Form.GetValues("hid_photo_remark");
List<int> intlist1 = new List<int>();
if (albumArr1 != null)
{
for (int i = 0; i < albumArr1.Length; i++)
{
string[] Arr = albumArr1[i].Split('|');
int img_id = Utils.ObjToInt(Arr[0]);
string original_path = Arr[1];
string thumb_path = Arr[2];
intlist1.Add(img_id);
//新增或者修改
if (img_id > 0)
{
var modelImg = db.ht_img.Where(x => x.id == img_id).FirstOrDefault();
modelImg.remark = remarkArr1[i];
modelImg.obj_id = model.id;
modelImg.original_path = original_path;
modelImg.thumb_path = thumb_path;
modelImg.sort = 99;
}
else
{
ht_img modelImg = new ht_img();
modelImg.add_time = DateTime.Now;
modelImg.remark = remarkArr1[i];
modelImg.obj_id = model.id;
modelImg.original_path = original_path;
modelImg.thumb_path = thumb_path;
modelImg.sort = 99;
db.ht_img.Add(modelImg);
}
}
}
//删除不存在的
db.ht_img.RemoveRange(db.ht_img.Where(x => x.obj_id == model.id && !intlist1.Contains(x.id)).ToList());
#endregion
db.SaveChanges();
return true;
46.后台上传文件
$function callback(img_url) {
$(th).parent().find(".upload-path").val(img_url);
layer.msg('选图成功', { icon: 1 });
}
<dl>
<dt>文件路径</dt>
<dd>
<asp:TextBox ID="txturl2" runat="server" CssClass="input normal upload-path" />
<div class="upload-box upload-img1"></div>
<span class="Validform_checktip">*上传文件本地必须也拥有此文件</span>
</dd>
</dl>
47.新闻列表推荐_list拇指按钮
<!--列表-->(头部列表)
<asp:Repeater ID="rptList" runat="server" OnItemCommand="rptList_ItemCommand">
=========
<td align="center">
<div class="btn-tools">
<asp:LinkButton ID="lbtnIsRed" CommandName="lbtnIsRed" runat="server" CssClass='<%# Convert.ToInt32(Eval("is_red")) == 2 ? "red selected" : "red"%>' ToolTip='<%# Convert.ToInt32(Eval("is_red")) == 1 ? "取消推荐" : "设置推荐"%>' />
</div>
</td>
=========(后台)
//设置操作
protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e)
{
ChkAdminLevel("news_list", HTEnums.ActionEnum.Edit.ToString()); //检查权限
int id = Convert.ToInt32(((HiddenField)e.Item.FindControl("hidId")).Value);
var model = db.ht_news.Where(x => x.id == id).FirstOrDefault();
switch (e.CommandName)
{
case "lbtnIsRed":
if (model.is_red == 2)
model.is_red = 1;
else
model.is_red = 2;
break;
}
db.SaveChanges();
RptBind();
}
48.SEO新闻TDK
(赋值)
webtitle.Text = model.seotitle;
webdescription.Text = model.seodesc;
webkeyword.Text = model.seokeys;
(增删)
model.seotitle = webtitle.Text;
model.seokeys = webkeyword.Text;
model.seodesc = webdescription.Text;
if (string.IsNullOrEmpty(model.seotitle.Trim()))
{
model.seotitle = model.title;
}
if (string.IsNullOrEmpty(model.seokeys.Trim()))
{
model.seokeys = model.title;
}
if (string.IsNullOrEmpty(model.seodesc.Trim()))
{
model.seodesc = model.title;
}
49.content的文本编辑器
model.content = this.txtContent.Value.Trim();
//把超链图片下载到本地服务器
model.content = new HT.Web.UI.AdminBllPage().GetContentImgUpload(model.content.Trim());
50.主站内容
SysConfigPage scp = new SysConfigPage();
protected string webname;
webname = scp.GetSysConfig().webname;
51.接口:查询两张表,问题对应答案
public Models.ModelResponse<List<dynamic>> GetGoodsCategoryList()
{
Models.ModelResponse<List<dynamic>> mr = new Models.ModelResponse<List<dynamic>>();
try
{
var list = db.ht_problem.Where(x => x.id > 0).OrderBy(x => x.sort).ToList();
if (list.Count() > 0)
{
mr.ErrCode = 0;
mr.ErrMsg = "成功";
List<dynamic> dylist = new List<dynamic>();
foreach (var item in list)
{
var list1 = db.ht_submit.Where(x => x.type == item.id).OrderBy(x => x.sort).ToList();
List<dynamic> classlist = new List<dynamic>();
foreach (var item1 in list1)
{
dynamic dyclass = new
{
id = item1.id,
title = item1.title,
};
classlist.Add(dyclass);
}
dynamic dy = new
{
id = item.id,
title = item.title,
class_list = classlist
};
dylist.Add(dy);
}
mr.Response = dylist;
return mr;
}
else
{
mr.ErrCode = 0;
mr.ErrMsg = "暂无内容";
return mr;
}
}
catch
{
mr.ErrCode = 1;
mr.ErrMsg = "服务器异常";
return mr;
}
}
52.福安类型后台多选
<dl>
<dt>所属类别</dt>
<dd>
<div class="rule-multi-porp">
<asp:CheckBoxList ID="cblCategoryId" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow"></asp:CheckBoxList>
</div>
</dd>
</dl>
#region 绑定类别=================================
private void TreeBind()
{
var list = db.ht_logo.Where(x => x.id > 0&&x.types==1).ToList();
cblCategoryId.Items.Clear();
foreach (var item in list)
{
string Title = item.title;
var id = item.id;
cblCategoryId.Items.Add(new ListItem(Title, id.ToString()));
}
}
#endregion
赋值==========
if (model.tage != null || model.tage.Contains(","))
{
string[] categoryArr = model.tage.Split(',');
for (int i = 0; i < cblCategoryId.Items.Count; i++)
{
for (int n = 0; n < categoryArr.Length; n++)
{
if (categoryArr[n].ToLower() == cblCategoryId.Items[i].Value.ToLower())
{
cblCategoryId.Items[i].Selected = true;
}
}
}
}
增改==========
//添加分类
string categoryArr = string.Empty;
if (string.IsNullOrEmpty(cblCategoryId.SelectedValue))
{
JscriptMsg("必须要选择产品分类才可保存数据!", string.Empty);
}
else
{
for (int i = 0; i < cblCategoryId.Items.Count; i++)
{
if (cblCategoryId.Items[i].Selected)
{
categoryArr += cblCategoryId.Items[i].Value + ",";
}
}
if (!string.IsNullOrEmpty(categoryArr))
{
model.tage = Utils.DelLastComma(categoryArr);
}
}
53.接口中后台的一个ID集合,(产品特色)
string[] features = item.feature.Split(',');
List<string> featurelist = new List<string>();
foreach (string fitem in features)
{
int fid = Convert.ToInt32(fitem);
ht_product_list product = db.ht_product_list.FirstOrDefault(x => x.id == fid);
if (product!=null)
{
featurelist.Add(product.title);
}
}
54.把网页加入收藏
<a href="javascript:;" onclick="return AddFavorite(window.location,document.title);">收藏</a>
<script>
function AddFavorite() {
try {
window.external.addFavorite(sURL, sTitle);
}
catch (e) {
try {
window.sidebar.addPanel(sTitle, sURL, "");
}
catch (e) {
alert("加入收藏失败,请使用Ctrl+D进行添加");
}
}
}
</script>
55.把id用逗号分隔存入cookie
string temp = string.Empty;
string cookie = Utils.GetCookie("cids");
if (string.IsNullOrEmpty(cookie))
{
temp = id.ToString();
}
else {
temp = cookie + "," + id.ToString();
}
Utils.WriteCookie("cids", temp);
mr.ErrCode = 0;
mr.ErrMsg = "成功";
mr.Response = cookie;
return mr;
56.去除逗号,用ID进行查询列表
string cookie = Utils.GetCookie("cids");
string[] cids = cookie.Split(',');
foreach (string cid in cids)
{
int id = Convert.ToInt32(cid);
ht_product product = db.ht_product.FirstOrDefault(x => x.id == id);
if (product != null)
{
dynamic dydata = new
{
id = product.id,
title = product.title,
img = siteConfig.weburl + product.img_url,
moneys = product.moneys,
address = product.address,
area = new HT.Web.UI.WebBllPage().getarea(Convert.ToInt32(product.area)),
};
list.Add(dydata);
}
}
//把id用逗号分隔存入缓存=======
string temp = string.Empty;
object cookie = CacheHelper.Get("cids");
if (cookie==null)
{
temp = id.ToString();
}
else {
temp = cookie.ToString() + "," + id.ToString();
}
CacheHelper.Insert("cids", temp, 51200);
mr.ErrCode = 0;
mr.ErrMsg = "成功";
mr.Response = cookie;
return mr;
//去除逗号,用ID进行查询列表在缓存========
object cookie = CacheHelper.Get("cids");
if (cookie!=null&&!string.IsNullOrEmpty(cookie.ToString()))
{
string[] cids = cookie.ToString().Split(',');
foreach (string cid in cids)
{
int id = Convert.ToInt32(cid);
ht_product product = db.ht_product.FirstOrDefault(x => x.id == id);
if (product != null)
{
dynamic dydata = new
{
id = product.id,
title = product.title,
img = siteConfig.weburl + product.img_url,
moneys = product.moneys,
address = product.address,
area = new HT.Web.UI.WebBllPage().getarea(Convert.ToInt32(product.area)),
};
list.Add(dydata);
}
}
}
57.用ajax来调用接口
<script>
function get_data() {
$.ajax({
url: "http://syfcapi.hai-tao.net/api/Product/GetCollectList",
type: "get",
dataType: "json",
data: {},
cache: false,
async: false,
success: function (e) {
var aa = e;
},
error: function (e) {
alert(e.statusText);
}
});
}
</script>
58.接口中删除站内信
db.ht_user_message.RemoveRange(db.ht_user_message.Where(x => x.user_id == user_id && intlist.Contains(x.id)).ToList());
59.详情页里面的JOSON集合(后台多选)
List<dynamic> centerlist = new List<dynamic>();
foreach (string fitem in center)
{
int fid = Convert.ToInt32(fitem);
ht_product_list product = db.ht_product_list.FirstOrDefault(x => x.id == fid);
if (product != null){
dynamic datadyp = new
{
img_url= siteConfig.weburl+product.img_url,
title=product.title
};
centerlist.Add(datadyp);
}
}
60.接口中文本框插入图片无法显示
string htmlContent = model.content.Replace("src=\"/upload", "src=\"" + scp.GetSysConfig(HTEnums.SiteSystem.sys_weburl) + "/upload");
content=item.content;
61.上传文件的类型
filetypes: "jpg,jpge"
62.对比前一个input框,不一样返回错误提示
datatype="*" recheck="password1" errormsg="两次输入的密码不一致"
63.如果只要为空,那么截取内容的前255个字符
if (string.IsNullOrEmpty(txtzhaiyao.Text))
model.zhaiyao = Utils.DropHTML(txtContent.Value, 255);
64.时间
<dl>
<dt>发布时间</dt>
<dd>
<asp:TextBox ID="txtaddtime" runat="server" CssClass="input rule-date-input" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" datatype="*" errormsg="请选择正确的日期" sucmsg=" " />
<span class="Validform_checktip">*如果大于当前时间,案例将定时发布</span>
</dd>
</dl>
txtaddtime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");//初始加载赋值
txtaddtime.Text = Convert.ToDateTime(model.addtime).ToString("yyyy-MM-dd");
model.addtime = Utils.ObjectToDateTime(txtaddtime.Text);
65.接口列表
addtime = Convert.ToDateTime(news_list.addtime).ToString("yyyy-MM-dd"),
66.将接口postdy提交中的文本拆分
dynamic eval_lists = JsonConvert.DeserializeObject<dynamic>(eval_list);
foreach (var item in eval_lists)
{
#region 获取参数
int order_goods_id = Utils.ObjToInt(item["order_goods_id"].ToString(), 0);
string content = item["content"].ToString();
string img_list = "";
try
{
img_list = item["img_list"].ToString();
}
catch (Exception)
{
img_list = "";
}
//评论内容
if (string.IsNullOrEmpty(content))
{
mr.ErrCode = 1;
mr.ErrMsg = "请填写评论内容";
return mr;
}
#endregion
}
第二案例(上面评论保存成功后保存相册)
#region 保存商品评价图片
dynamic diclist = JsonConvert.DeserializeObject<dynamic>(img_list);
if (img_list != null)
{
foreach (var img_item in diclist)
{
string newimg = img_item["img_url"].ToString();
if (string.IsNullOrEmpty(newimg))
{
continue;
}
ht_img imgmodel = new ht_img();
imgmodel.obj_id = commentmodel.id;
imgmodel.thumb_path = img_item["img_url"].ToString();
imgmodel.original_path = imgmodel.thumb_path;
imgmodel.add_time = DateTime.Now;
imgmodel.type = Convert.ToInt32(HTEnums.Img_type.evaluation);
db.ht_img.Add(imgmodel);
db.SaveChanges();
model.is_eva = 2;
}
}
#endregion
67.通过分类查名称
<td align="center"><%# new WebBllPage().GetCaseTitle(Convert.ToInt32(Eval("cate_id")))%> </td>
68.列表页面的页面页码功能
int pageSize = 10;
int page = HTRequest.GetQueryInt("page", 1);
var pagelist = list.Skip(pageSize * (page - 1)).Take(pageSize).ToList();
69.
//今日收益
var amountlog1 = db.ht_user_amount_log.Where(x => x.user_id == usermodel.id & x.value > 0 & x.add_time.Year == DateTime.Now.Year & x.add_time.Month == DateTime.Now.Month & x.add_time.Year == DateTime.Now.Day).ToList();
foreach (var item in amontlist)
{
money1 += (decimal)item.value;
}
//七天之内
DateTime now = DateTime.Now.AddDays(-7);
var amount_list = db.ht_user_amount_log.Where(x => x.user_id == usermodel.id & x.value > 0).ToList();
foreach (var item in amount_list)
{
if (item.add_time > now)
{
money7 += (decimal)item.value;
}
}
70.根据获取的ID查类型标题
name = db.ht_downloadtype.Where(p => p.Id == id).Select(p => p.TypeName).FirstOrDefault();
71.
if (!IsPostBack)
{
if (!string.IsNullOrEmpty(Request.QueryString["id"]))
{
id = Utils.StrToInt(Request.QueryString["id"], 0);
name = db.ht_downloadtype.Where(p => p.Id == id).Select(p => p.TypeName).FirstOrDefault();
}
Bind(id);
}
72.
#region 固定分类标题
protected string getcategory(int id)
{
string title = "";
switch (id)
{
case 1:
title = "最新公告";
break;
case 2:
title = "代理价格";
break;
case 3:
title = "营在素材";
break;
}
return title;
}
#endregion
73.距离多少小时结束
//时间相减相差多少小时
public string GetHour(DateTime endtime)
{
DateTime t1 = endtime;
DateTime t2 = DateTime.Now;
System.TimeSpan t3 = t1 - t2;
double getHours = t3.TotalHours;
if (getHours < 0)
{
return "<span><em>" + ( - Math.Round(getHours, 1)) + "小时前</em>结束</span>";
}
else
{
return "<span><em>" + Math.Round(getHours, 1) + "小时后</em>结束</span>";
}
}
74.循环里面暂无内容
<%=showlist.Items.Count==0?"<div style='width:100%; line-height:350px; text-align:center; color:#999'>暂无数据</div>":"" %>
75. 提取li里面的data-title链接
<li class="<%=locheader=="校友中心"?"act":"" %>" data-title="news">
var url = $("li[class='act']").attr("data-title");
76.登录前后改内容
protected bool islogin;
if (HttpContext.Current.Session[HTKeys.SESSION_USER_INFO]!=null)
{
islogin = true;
}
前:<%=islogin? "style='display:none'":"" %>
77.span有样式,给隐藏的input给值1,没有样式给0
<script>
$(".button_board h4 span").click(function () {
$(this).toggleClass("active")
if ($(this).hasClass("active")) {
$("#agree").val(1);
}
else {
$("#agree").val(0);
}
})
</script>
78.check选中表单
string 78.check= HTRequest.GetFormString78.check();
//验证注册协议
if (ckagreement != "on")
{
context.Response.Write("{\"status\":0, \"msg\":\"对不起,不同意用户协议无法注册\"}");
return;
}
79.
筛选直接跳转传值用<123=123?"active":"">
筛选点按钮传值用
<script type="text/javascript">
function clicksss() {
var positions = "";
var types = "";
$("#positions dd").each(function () {
if ($(this).hasClass("active")) {
positions = $(this).attr("data-id");
}
})
$("#types dd").each(function () {
if ($(this).hasClass("active")) {
types = $(this).attr("data-id");
}
})
location.href = "media_enquiries.aspx?area=" + positions + "&&category=" + types;
}
</script>
80,行内的click
onclick ='{if (confirm("您确定要取消收藏吗?")){return true;}return false;}'
81.当前页勾选框JS提示
$("#sub").click(function () {
if ($("input[type='checkbox']").is(':checked') == false) {
alert("请阅读投标规则和隐私保护!");
window.location.href = "tender_info.aspx?id=" + id;
return false;
}
//window.location.href = "tender_info.aspx?myar=1&i=692";
});
82.身份证号验证
if (wbp.Check(id_card) == false)
public bool Check(string idcard)
{
if (idcard.Length == 18)
{
if (ValidBirthday(idcard) && ValidateCode(idcard))
{
return true;
}
}
return false;
}
83.后台页面参数错误提示
if (string.IsNullOrEmpty(pay_order_no))
{
Response.Redirect("error.aspx?msg=对不起,参数错误");
return;
}
84.商城状态
待付款 x.is_status == 1 && x.payment_status == 1
待发货 x.is_status == 2 && x.express_status == 1
待收货 x.is_status == 2 && x.express_status == 2 && x.payment_status == 2
待评价 x.is_status == 3 && x.express_status == 2 && x.payment_status == 2
退/换货 x.is_status == 3 && x => x.is_return == 2
95,查询今天
x.addtime.Value.Year == DateTime.Now.Year && x.addtime.Value.Month == DateTime.Now.Month && x.addtime.Value.Day == DateTime.Now.Day
96.字符串中是否有逗号
model.select_like.Contains(",")
97.最后一条信息的字段返回none
var indexlists = db.ht_news.Where(x => x.id > 0 && x.type == 7).OrderBy(x => x.sort).ThenByDescending(x => x.id).ToList();
int num = indexlists.Count()-1;
List<dynamic> dylist = new List<dynamic>();
for (int i = 0; i < indexlists.Count; i++)
{
string s = num == i ? "none" :"";
dynamic dydate = new {
title=indexlists[i].title,
abstracts=indexlists[i].abstracts,
m = s
};
dylist.Add(dydate);
}
indexlist.DataSource = dylist;
indexlist.DataBind();
98.身份证
/// <summary>
/// 验证身份证规则
/// </summary>
/// <param name="idcard">身份证号</param>
/// <returns></returns>
private static bool ValidateCode(string idcard)
{
int sum = 0;
char[] chars = idcard.ToCharArray();
List<string> list = chars.Select(c => c.ToString()).ToList();
if (list[17].ToLower() == "x")
{
list[17] = "10";
}
for (int i = 0; i < 17; i++)
{
sum += _factors[i] * Convert.ToInt32(list[i]);
}
//获取验证位置
int position = sum % 11;
if (list[17].Equals(_codes[position].ToString()))
{
return true;
}
return false;
}
99.点击它给样式,其他的同级兄弟移除样式
$(this).click(function () {
$(this).addClass("active").siblings().removeClass("active");
});
100.在一个列表循环中找到一个数值
var list = db.ht_article_type.Where(x => x.parent_id == 0).OrderBy(x => x.sort).ToList();
foreach (var item in list)
{
if (item.title == "日记")
{
this.id = item.id;
}
}
101,循环获取用户名发送
string[] arrUserName = txtUserName.Text.Trim().Split(',');
foreach (string username in arrUserName)
{
var usermodel = db.ht_users.Where(x => x.user_name == username).FirstOrDefault();
if (usermodel != null)
{
ht_user_message model = new ht_user_message();
model.type = 1;
model.post_user_name = "系统管理员";
model.accept_user_name = usermodel.user_name;
model.title = title;
model.content = content;
model.post_time = DateTime.Now;
model.is_read = 1;
db.ht_user_message.Add(model);
}
}
102.选择其中一个radio获取它的值
function tiaozh
uan() {
var val = $('input:radio[name="check_pay"]:checked').val();
}
103.点击事件
一、 $(".z_wx_click").click(function () {
$(".z_wx").add(".z_back").fadeIn();
});
二、function tiaozhuan() {
}
104.搜索框点击回车进行搜索
function searchbaidukeyword() {
var keywords = $("#searchText").val();
location.href = "my_select.aspx?keywords=" + keywords;
}
$('#searchText').bind('keypress',function(event){
if(event.keyCode == 13)
{
location.href = "my_select.aspx?keywords=" + $('#searchText').val();
}
});
function searchbaidukeyword() {
var keywords = $("#searchText").val();
document.onkeydown = function (e) {
var a = e || window.event;//加这个火狐下不会报 event is undefind
if (a.keyCode == 13) {
var keywords = $("#searchText").val();
window.location.href = "what.aspx?keywords=" + keywords;
}
}
}
105.文件下载
.apk application/vnd.android
106,运行环境没有装
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i
107.循环绑定数据,内容不同
var showlistss = db.ht_goods_category.Where(x => x.id > 0 && x.class_layer == 1).OrderBy(x => x.sort).ThenByDescending(x => x.id).ToList();
List<dynamic> dylist = new List<dynamic>();
for (int i = 0; i < showlistss.Count; i++)
{
int about_i = showlistss[i].id;
int cate_num = db.ht_goods_category.Where(x => x.id > 0 && x.class_list.Contains("," + about_i + ",") && x.class_layer == 2).Count();
//加下拉箭头样式
string s = cate_num > 0 ? "menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children menu-item-4501" : "z_axia menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children menu-item-4501";
//显示隐藏下拉二级列表
string c = cate_num > 0 ? "" : "none";
//二级是否需要跳转链接
string a = cate_num > 0 ? "#" : "product-" + showlistss[i].id + ".html";
dynamic dydate = new
{
id = showlistss[i].id,
title = showlistss[i].title,
m = s,
n = c,
url =a
};
dylist.Add(dydate);
}
showlist.DataSource = dylist;
showlist.DataBind();
108.自动判断是不是微信内部浏览器(两个括号自动启动方法)
(function () {
var agent = navigator.userAgent.toLowerCase();
if (agent.match(/MicroMessenger/i) == "micromessenger") {
$(".list_dow ul li").click(function () {
$(".zh_ts").show();
})
$(".zh_ts").click(function () {
$(this).hide();
})
return;
} else {
return false;
}
}())
判断是安卓还是苹果手机的浏览器
var u = navigator.userAgent;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
if (isAndroid) {
alert("系统不支持下载IOSAPP");
} else if (isiOS) {
alert("系统不支持下载安卓APP");
return;
}
109.页面加载完时,运动JS
$(document).ready(function () {
$(".school_a1").click(function () {
。。。。});
});
110.SEOtitle为空用标题填充
model.seo_title = txtseotitle.Text.Trim();
if (string.IsNullOrEmpty(txtseotitle.Text.Trim()))
{
model.seo_title = Utils.DropHTML(txttitle.Text);
}
else
{
model.seo_title = txttitle.Text;
}
111.提交表单
<script src="../js/jquery.min.1.10.2.js"></script>
<!-- 弹出层插件 -->
<link href="../js/layer/skin/layer.css" rel="stylesheet" />
<script src="../scripts/laydate/laydate.js"></script>
<link href="../scripts/laydate/need/laydate.css" rel="stylesheet" />
<script src="../js/layer/layer.js"></script>
<script src="../scripts/jquery/Validform_v5.3.2_min.js"></script>
<script src="../scripts/jquery/AjaxInitForm.js"></script>
<script src="../scripts/jquery/jquery.form.min.js"></script>
112,批量上传图片后上传
<div>
<dl id="imglist">
<dd>
<img src="/images/a1.png" onclick="doUpload(this,2)">
</dd>
</dl>
</div>
<script>
var thup;
var type;
function doUpload(_thup, _type){
var num = 0;
$("input[name=hidimgpath]").each(function () {
num++;
})
thup = _thup;
type = _type;
var theFrame = document.getElementById("uploadframe");
if (theFrame) {
theFrame = theFrame.contentWindow;
//第一个参数未回调函数 第二个参数未切割缩略图宽高(为空不切图)
theFrame.selectAndUpload('callback');
}
}
//单张上传回调
function callback(newPath, Thumb_newPath) {
if (type == 1) {
$(thup).attr("src", newPath);
$("#hid_img1").val(newPath);
}
else {
var dghmtl = " <dd><img src='" + newPath + "' onclick='onDel(this)' name=\"hidimgpath\" > </dd>";
$("#imglist").append(dghmtl);
}
}
//删除图片
function onDel(th) {
$(th).parent().remove();
}
$(function () {
AjaxInitForm("form1", "btnSubmit", "msgid");
var img_lists = [];
$('#btnSubmit').click(function () {
$("img[name='hidimgpath']").each(function () {
var ss = $(this).attr("src");
img_lists.push(ss);
})
$("#img_listsss").val(img_lists);
});
})
</script>
tool里面保存
if (img_listss != "")
{
int typea = Convert.ToInt32(HTEnums.Img_type.an_limg);
string[] hidimgpathArr = img_listss.Split(',');
if (hidimgpathArr.Length > 0)
{
//保存相册
#region
for (int i = 0; i < hidimgpathArr.Length; i++)
{
ht_img img_model = new ht_img();
img_model.add_time = DateTime.Now;
img_model.obj_id = model.id;
img_model.thumb_path = hidimgpathArr[i].ToString();
img_model.original_path = hidimgpathArr[i].ToString();
img_model.sort = (99 + i);
img_model.type = typea;
db.ht_img.Add(img_model);
db.SaveChanges();
}
#endregion
}
}
113,表单提交,包括状态3的半透明框
var urlcode = '../tools/submit_ajax.ashx?action=message_add';
$.ajax({
type: "POST",
dataType: "json",
url: urlcode,
data: { "txtname": txtname, "txtmobile": txtmobile },
success: function (data) {
if (data.status == 1) {
layer.msg(data.msg, { icon: 1 });
setTimeout(function () {
location.href = data.url;
}, 2000);
} else if(data.status == 2) {
layer.msg(data.msg, { icon: 2, shift: 6 });
if (typeof (data.url) != "undefined") {
setTimeout(function () {
location.href = data.url;
}, 2000);
}
}
else {
layer.msg('提交成功', { time: 2000 }, function () {
var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
parent.location.href = data.url;
parent.layer.close(index);
});
};
}
});
114.百度地图
<div style="width: 704px; height: 406px;" id="dituContent"></div>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=8coBALVe9p1VOFMwPP9DGrGkg2cVjRGG"></script>
<script type="text/javascript">
//创建和初始化地图函数:
function initMap() {
createMap();//创建地图
setMapEvent();//设置地图事件
addMapControl();//向地图添加控件
addMarker();//向地图中添加marker
}
//创建地图函数:
function createMap() {
var map = new BMap.Map("dituContent");//在百度地图容器中创建一个地图
var point = new BMap.Point(121.438886, 31.205559);//定义一个中心点坐标
map.centerAndZoom(point, 17);//设定地图的中心点和坐标并将地图显示在地图容器中
window.map = map;//将map变量存储在全局
}
//地图事件设置函数:
function setMapEvent() {
map.enableDragging();//启用地图拖拽事件,默认启用(可不写)
map.enableScrollWheelZoom();//启用地图滚轮放大缩小
map.enableDoubleClickZoom();//启用鼠标双击放大,默认启用(可不写)
map.enableKeyboard();//启用键盘上下左右键移动地图
}
//地图控件添加函数:
function addMapControl() {
//向地图中添加缩放控件
var ctrl_nav = new BMap.NavigationControl({ anchor: BMAP_ANCHOR_TOP_LEFT, type: BMAP_NAVIGATION_CONTROL_LARGE });
map.addControl(ctrl_nav);
//向地图中添加缩略图控件
var ctrl_ove = new BMap.OverviewMapControl({ anchor: BMAP_ANCHOR_BOTTOM_RIGHT, isOpen: 1 });
map.addControl(ctrl_ove);
//向地图中添加比例尺控件
var ctrl_sca = new BMap.ScaleControl({ anchor: BMAP_ANCHOR_BOTTOM_LEFT });
map.addControl(ctrl_sca);
}
//标注点数组
var markerArr = [{ title: "学院地址", content: "上海市徐汇区华山路1954号", point: "121.438715|31.205744", isOpen: 0, icon: { w: 23, h: 25, l: 46, t: 21, x: 9, lb: 12 } }
];
//创建marker
function addMarker() {
for (var i = 0; i < markerArr.length; i++) {
var json = markerArr[i];
var p0 = json.point.split("|")[0];
var p1 = json.point.split("|")[1];
var point = new BMap.Point(p0, p1);
var iconImg = createIcon(json.icon);
var marker = new BMap.Marker(point, { icon: iconImg });
var iw = createInfoWindow(i);
var label = new BMap.Label(json.title, { "offset": new BMap.Size(json.icon.lb - json.icon.x + 10, -20) });
marker.setLabel(label);
map.addOverlay(marker);
label.setStyle({
borderColor: "#808080",
color: "#333",
cursor: "pointer"
});
(function () {
var index = i;
var _iw = createInfoWindow(i);
var _marker = marker;
_marker.addEventListener("click", function () {
this.openInfoWindow(_iw);
});
_iw.addEventListener("open", function () {
_marker.getLabel().hide();
})
_iw.addEventListener("close", function () {
_marker.getLabel().show();
})
label.addEventListener("click", function () {
_marker.openInfoWindow(_iw);
})
if (!!json.isOpen) {
label.hide();
_marker.openInfoWindow(_iw);
}
})()
}
}
//创建InfoWindow
function createInfoWindow(i) {
var json = markerArr[i];
var iw = new BMap.InfoWindow("<b class='iw_poi_title' title='" + json.title + "'>" + json.title + "</b><div class='iw_poi_content'>" + json.content + "</div>");
return iw;
}
//创建一个Icon
function createIcon(json) {
var icon = new BMap.Icon("http://app.baidu.com/map/images/us_mk_icon.png", new BMap.Size(json.w, json.h), { imageOffset: new BMap.Size(-json.l, -json.t), infoWindowOffset: new BMap.Size(json.lb + 5, 1), offset: new BMap.Size(json.x, json.h) })
return icon;
}
initMap();//创建和初始化地图
</script>
115.替换文本
string cefp = cefp.Replace(".aspx", "").Replace(".html", "");
把aspx替换空,html替换为空
116.请求当前虚拟路径的地址
//当前网页目录和名称
string cefp = Request.CurrentExecutionFilePath;
117.点击按钮后,调用方法给样式
function addclass() {
$("p:first").addClass("hiddenaddcss");
}
相关文章
- 一篇笔记整理JVM工作原理
- SpringMVC学习笔记 - 第一章 - 工作流程、Bean加载控制、请求与响应(参数接收与内容返回)、RESTful
- [原创]java WEB学习笔记79:Hibernate学习之路--- 四种对象的状态,session核心方法:save()方法,persist()方法,get() 和 load() 方法,update()方法,saveOrUpdate() 方法,merge() 方法,delete() 方法,evict(),hibernate 调用存储过程,hibernate 与 触发器协同工作
- tornado 学习笔记10 Web应用中模板(Template)的工作流程分析
- 转:HashMap的工作原理,及笔记
- 【工作笔记二】ASP.NET MVC框架下使用MVVM模式
- IOS工作笔记(九)
- sip工作笔记 2
- php工作笔记1
- php工作笔记5