本文共 2031 字,大约阅读时间需要 6 分钟。
作为业余程序猿,没能转型成功,也只能继续coding了。但是不干则已,干则须专。要不然怎么养活老小啊。生存的技能可是多多益善。
新的工作是做web开发的。最近再熟悉相关知识。公司自有的一些常用方式,怎么也是没能记住。这里我罗列一些,方便以后工作中使用。
1.asp.net 删除cookie
技术是创建一个与要删除的 Cookie 同名的新 Cookie,并将该 Cookie 的到期日期设置为早于当前日期的某个日期。当浏览器检查 Cookie 的到期日期时,浏览器便会丢弃这个现已过期的 Cookie。下面的代码示例演示删除应用程序中所有可用 Cookie 的一种方法:
//使用完了,清除指定Cookie HttpCookie cookieID = new HttpCookie("selected"); cookieID.Expires = DateTime.Now.AddHours(-24); Response.Cookies.Add(cookieID);2 字符串转int :
int.Parse =>> Util.TrimIntNull
int orderSysNo = Util.TrimIntNull(Request.QueryString["sysno"].ToString());
this.isSelected = Util.TrimBoolNull(Request.QueryString["select"].ToString());
3页面跳转方式
1. bodyOnLoad方式
CS:
protected string bodyOnLoad;
ASPX:
<body οnlοad="<%=bodyOnLoad%>">
跳转
bodyOnLoad = "javascript:window.opener.__doPostBack('btnSearch','btnSearch');window.close(); return false;";
或者
bodyOnLoad = "javascript:window.opener.location.href='OrderOpt.aspx?opt=select&sysno=" +
orderSysNo + "';window.close(); return false;";不传参数,直接返回
bodyOnLoad = "javascript:window.opener.location.href=window.opener.location.href;window.close(); return false;";
2 asp 事件触发方式
跳转
btnAdd.Attributes["onclick"] = "javascript:openWindowS3('CustomerAddressOpt.aspx?customerSysNo=" + sysNo + "'); return false;";
这种方式下 btnAdd_click事件将不会再触发
2-1 按钮下跳转
string html = string.Format(@"<script language=javascript>window.open('AddOrderItem.aspx?opt=add&orderId={0}','',
'alwaysRaised=1,dependent=1,resizable=0,scrollbars,width=650,height=550'); </script>", orderId);Response.Write(html);
4 子页回传参数给父页使用
第一个是自定义控件
bodyOnLoad = "javascript:window.opener.document.all['" + this.clientID + "$txtProductID'].value='" + oInfo.ProductID + "';"; bodyOnLoad += "window.opener.document.all['" + this.clientID + "$txtProductSysNo'].value='" + oInfo.SysNo + "';";bodyOnLoad += "window.opener.document.getElementById('txtProductName').disabled = true;";
bodyOnLoad += "window.close(); return false;";
5枚举使用
LblStatus.Text = AppEnum.GetJackyOrderStatus(order.Status);
int status= (int)AppEnum.JackyOrderStatus.Normal;
转载地址:https://blog.csdn.net/jacky_zh/article/details/39396667 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!