真爱无限的知识驿站

学习积累技术经验,提升自身能力

子站点间使用同一个cookie的问题

//c# code

        public string testcookie(string id)
        {
            HttpCookie Cookie;
            Cookie = Request.Cookies["testcookie"];
            string GotoDomain = System.Configuration.ConfigurationManager.AppSettings["GotoDomain"].ToString();
            if (string.IsNullOrEmpty(id))//读取
            {
                string test1 = "";
                if (Cookie != null)
                {
                    test1 = Common.OperateText.Decrypt(Cookie["test1"].ToString());
                }
                return ("{"读取到的test1":"" + test1 + "","code":"200"}");
            }
            else//写入
            {
                Cookie = new HttpCookie("testcookie");
                string test1 = id + "-" + DateTime.Now + GotoDomain;
                Cookie["test1"] = Common.OperateText.Encrypt(test1);
                Cookie.Domain = GotoDomain;
                Cookie.Path = "/";
                Cookie.Secure = false;
                Cookie.Expires = DateTime.Now.AddHours(24);
                Response.Cookies.Add(Cookie);
                return ("{"写入的test1":"" + test1 + "","code":"200"}");
            }
        }


[转载]windows server2008r2 下载


C#winform批量给图片加水印代码

//文件下载,里面有exe可直接运行

http://download.csdn.net/detail/pukuimin1226/6001759

.net mvc中上传图片生成缩略图

Code:

        #region CreateThumbnail
        /// <summary>
        /// 生成缩略图
        /// </summary>
        /// <param name="uploadObject">上传的HttpPostedFile或图片物理路径</param>
        /// <param name="uploaddir">上传文件夹相对路径</param>
        /// <param name="ext">后缀(如:.jpg)</param>
        /// <param name="t_width">缩略图宽</param>
        /// <param name="t_height">缩略图高</param>
        /// <param name="filename">文件夹,不含路径和后缀</param>
        /// <param name="tm">枚举类-缩略图的样式</param>
        /// <returns>返回生成图片的路径</returns>
        public static string CreateThumbnail(object uploadObject, string uploaddir, string ext, int t_width, int t_height, string filename, ThumbModel tm)
        {
            System.Drawing.Image thumbnail_image = null;
            System.Drawing.Image original_image = null;
            System.Drawing.Bitmap final_image = null;
            System.Drawing.Graphics graphic = null;
            MemoryStream ms = null;


js与flash交互操作1


//flash里传送值


'<param name="flashvars" value="' + this.getFlashVars() + '" />'

//flash里获取值

this.uploadURL=root.loaderinfo.parameters.uploadURL


SWFUpload.prototype.getFlashVars = function () {

flash 上传文件的actionscript

import flash.net.FileReference;
import flash.net.URLRequest;
import flash.net.FileFilter;
import flash.display.Sprite;
import flash.events.*;



var fileRef = new FileReference();
var fileListener = new Object();
var totalBytes:Number = 0;
var uploadedBytes:Number = 0;

C#中npoi操作Excel[版本2.0.1读写2003、2007格式]

 2.0.1npoi的dll文件下载:NPOI2.0.1.zip


       public static void test1()
       {
           NpoiHelper np = new NpoiHelper();
           DataTable dt1 = np.ReadExcel(AppDomain.CurrentDomain.BaseDirectory + "1测试数据.xls", 2).Tables[0];//读2003格式数据
           DataSet ds1 = new DataSet();
           ds1.Tables.Add(dt1.Copy());
           ds1.AcceptChanges();
           string SaveFileName = "output1.xls";
           np.CreateExcel2003(SaveFileName, "sheet001", ds1, 0);//写2003格式数据

子窗体与父窗体传值操作的js示例

//返回值给父窗体
function returnParent(value) {//获取子窗体返回值
   var parent = window.dialogArguments; //获取父页面
   //parent.location.reload(); //刷新父页面
   if (parent != null && parent != "undefined") {
       window.returnValue = value; //返回值

js控制滚动条示例

function runToTop(){
currentPosition=document.documentElement.scrollTop || document.body.scrollTop;
currentPosition-=10;
if(currentPosition>0)
{
window.scrollTo(0,currentPosition);
}


使用LitJSON.dll处理json格式的数据示例

using LitJson;
       //可到 http://sourceforge.net/projects/litjson/?source=dlp  下载
       protected void Page_Load(object sender, EventArgs e)
       {
           String str = "{'name':'j1','id':1,'items':[{'itemid':1001,'itemname':'it1'},{'itemid':1002,'itemname':'it2'}]}";
           //*** 读取JSON字符串中的数据 *******************************            
           JsonData jd = JsonMapper.ToObject(str);
           String name = (String)jd["name"];
           int id = (int)(jd["id"]);
           Response.Write(string.Format("name:{0},id:{1}<br/>",name,id));
           JsonData jdItems = jd["items"];

}


<< < 11 12 13 14 15 16 17 18 19 20 > >>

Powered By Z-BlogPHP 1.7.3

Copyright 2024-2027 pukuimin Rights Reserved.
粤ICP备17100155号