随笔 - 7  文章 - 0 评论 - 0 trackbacks - 0

FrameSet左右收缩代码:

主页面:

<frameset name="MainFrame" rows="*" cols="200,8,*" framespacing="0" frameborder="0" border="0" id="MainFrame">
    <frame name="LeftFrame"  src="left.aspx"  scrolling="auto" noresize="true" >
    <frame name="HideFrame" src="HideBar.aspx" scrolling="no" noresize="true">
    <frame name="WorkFrame" src="content.aspx">
</frameset>

 

HideBar.aspx代码:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TreeHideBar.aspx.cs" Inherits="Energy_TreeHideBar" %>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>NavigationHide</title>
<style type="text/css">
<!--
body {
 margin-left: 0px;
 margin-top: 0px;
 background-image: url(../App_Themes/Image/bar.gif);
 border-right: #005AC5 1px solid;
}
-->
</style>
</head>
<script  language="JavaScript"  type ="text/javascript">  

function ChangeVisible()
{
 if(parent.document.getElementById('MainFrame').cols != "0,8,*")
 {
  parent.document.getElementById('MainFrame').cols = "0,8,*";
  document.all.menuSwitch.innerHTML = "<a href='#' onclick='ChangeVisible();'><img src='index_arrow2.gif' width='8' height='48' border='0'></a>";
  
 }
 else
    {
     parent.document.getElementById('MainFrame').cols = "200,8,*";
  document.all.menuSwitch.innerHTML = "<a href='#' onclick='ChangeVisible();'><img src='index_arrow1.gif' width='8' height='48' border='0'></a>";  
    }
}
  </script>
<body >

<table width="8" height="100%" border="0" cellpadding="0" cellspacing="0" background="Image/bar.gif">
<tr>
<td valign="middle" id="menuSwitch"><a href="#" onclick="ChangeVisible();"><img src="index_arrow1.gif" width="8" height="48" border="0"></a></td>
</tr>

</table>
</body>
</html>

 

posted @ 2009-12-29 09:26 kenryuu 阅读(192) 评论(0) 编辑

 

http://m.jdd.blog.163.com/blog/static/52525241200992092344168/

http://hi.baidu.com/zonecens/blog/item/5a94be8f7c8d89f2503d9266.html

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Collections.Generic;
using System.Text;

using System.Globalization;


public partial class TestDate : System.Web.UI.Page
{
    private static ChineseLunisolarCalendar calendar = new ChineseLunisolarCalendar();
    private static string ChineseNumber = "〇一二三四五六七八九";
    public const string CelestialStem = "甲乙丙丁戊己庚辛壬癸";
    public const string TerrestrialBranch = "子丑寅卯辰巳午未申酉戌亥";
    public static readonly string[] ChineseDayName = new string[] {
            "初一","初二","初三","初四","初五","初六","初七","初八","初九","初十",
            "十一","十二","十三","十四","十五","十六","十七","十八","十九","二十",
            "廿一","廿二","廿三","廿四","廿五","廿六","廿七","廿八","廿九","三十"};
    public static readonly string[] ChineseMonthName = new string[] { "正", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "腊" };

    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Write(DateTime.Now.ToString()+"<br>");
        Response.Write(GetChineseDate(DateTime.Now));

    }
    private void Transform(DateTime dt)
    {
       
    }
    /// <summary>
    /// 获取一个公历日期对应的完整的农历日期
    /// </summary>
    /// <param name="time">一个公历日期</param>
    /// <returns>农历日期</returns>
    public string GetChineseDate(DateTime time)
    {
        string strY = GetYear(time);
        string strM = GetMonth(time);
        string strD = GetDay(time);
        string strSB = GetStemBranch(time);
        string strDate = strY + "(" + strSB + ")年 " + strM + "月 " + strD;
        return strDate;
    }
    /// <summary>
    /// 获取一个公历日期的农历干支纪年
    /// </summary>
    /// <param name="time">一个公历日期</param>
    /// <returns>农历干支纪年</returns>
    public string GetStemBranch(DateTime time)
    {
        int sexagenaryYear = calendar.GetSexagenaryYear(time);
        string stemBranch = CelestialStem.Substring(sexagenaryYear % 10 - 1, 1) + TerrestrialBranch.Substring(sexagenaryYear % 12 - 1, 1);
        return stemBranch;
    }

    /// <summary>
    /// 获取一个公历日期的农历年份
    /// </summary>
    /// <param name="time">一个公历日期</param>
    /// <returns>农历年份</returns>
    public string GetYear(DateTime time)
    {
        StringBuilder sb = new StringBuilder();
        int year = calendar.GetYear(time);
        int d;
        do
        {
            d = year % 10;
            sb.Insert(0, ChineseNumber[d]);
            year = year / 10;
        } while (year > 0);
        return sb.ToString();
    }


    /// <summary>
    /// 获取一个公历日期的农历月份
    /// </summary>
    /// <param name="time">一个公历日期</param>
    /// <returns>农历月份</returns>
    public string GetMonth(DateTime time)
    {
        int month = calendar.GetMonth(time);
        int year = calendar.GetYear(time);
        int leap = 0;

        //正月不可能闰月
        for (int i = 3; i <= month; i++)
        {
            if (calendar.IsLeapMonth(year, i))
            {
                leap = i;
                break; //一年中最多有一个闰月
            }

        }
        if (leap > 0) month--;
        return (leap == month + 1 ? "闰" : "") + ChineseMonthName[month - 1];
    }


    /// <summary>
    /// 获取一个公历日期的农历日
    /// </summary>
    /// <param name="time">一个公历日期</param>
    /// <returns>农历日</returns>
    public string GetDay(DateTime time)
    {
        return ChineseDayName[calendar.GetDayOfMonth(time) - 1];
    }
}

posted @ 2009-12-22 09:09 kenryuu 阅读(261) 评论(0) 编辑

这是通过在Global.asax文件中配置Application来统计的方法......


using System;
using System.Collections;
using System.ComponentModel;
using System.Web;
using System.Web.SessionState;
using System.IO ;

namespace movie
{
/// <summary>
/// Global 的摘要说明。
/// </summary>
public class Global : System.Web.HttpApplication
{
   /// <summary>
   /// 必需的设计器变量。
   /// </summary>
   private System.ComponentModel.IContainer components = null;

   public Global()
   {
    InitializeComponent();
   }
 
   protected void Application_Start(Object sender, EventArgs e)
   {
             Application["conn"]="Server=localhost;database=movie;uid=sa;pwd='zcc';";
    Application["user_sessions"] = 0;
    Application["counter_num"]=0;


    uint count=0;
    StreamReader srd;
    //取得文件的实际路径
    string file_path=Server.MapPath ("counter.txt");
    //打开文件进行读取
    srd=File.OpenText (file_path);
    while(srd.Peek ()!=-1)
    {
     string str=srd.ReadLine ();
     count=UInt32.Parse (str);
    }
    object obj=count;
    Application["counter"]=obj;
    srd.Close ();

   }

   protected void Session_Start(Object sender, EventArgs e)
   {
    Application.Lock();
    Application["user_sessions"] = (int)Application["user_sessions"] + 1;
    Application.UnLock();

    Application.Lock ();
    //数值累加,注意这里使用了装箱(boxing)
    uint jishu=0;
    jishu=(uint)Application["counter"];
    jishu=jishu+1;
    object obj=jishu;
    Application["counter"]=obj;
    //将数据记录写入文件
    string file_path=Server.MapPath ("counter.txt");
    StreamWriter fs=new StreamWriter(file_path,false);
    fs.WriteLine (jishu);
    fs.Close ();
    Application.UnLock ();


   }

   protected void Application_BeginRequest(Object sender, EventArgs e)
   {

//    Application.Lock();
//    Application["counter_num"]=(int)Application["counter_num"]+1;
//    Application.UnLock();

   }

   protected void Application_EndRequest(Object sender, EventArgs e)
   {

   }

   protected void Application_AuthenticateRequest(Object sender, EventArgs e)
   {

   }

   protected void Application_Error(Object sender, EventArgs e)
   {

   }

   protected void Session_End(Object sender, EventArgs e)
   {
    Application.Lock();
    Application["user_sessions"] = (int)Application["user_sessions"] - 1;
    Application.UnLock();

   }

   protected void Application_End(Object sender, EventArgs e)
   {

    uint js=0;
    js=(uint)Application["counter"];
    //object obj=js;
    //Application["counter"]=js;
    //将数据记录写入文件
    string file_path=Server.MapPath ("counter.txt");
    StreamWriter fs=new StreamWriter(file_path,false);
    fs.WriteLine(js);
    fs.Close ();


   }
  
   #region Web 窗体设计器生成的代码
   /// <summary>
   /// 设计器支持所需的方法 - 不要使用代码编辑器修改
   /// 此方法的内容。
   /// </summary>
   private void InitializeComponent()
   {   
    this.components = new System.ComponentModel.Container();
   }
   #endregion
}
}

posted @ 2009-12-22 09:05 kenryuu 阅读(171) 评论(0) 编辑
<div class="list-b comm-info"><IFRAME id=baiduframe marginWidth=0 frameSpacing=0 marginHeight=0 src="http://unstat.baidu.com/bdun.bsc?tn=446466620_pg&cv=0&cid=1094172&csid=242&bgcr=ffffff&ftcr=000000&urlcr=0000ff&tbsz=185&sropls=2,99&insiteurl=pcsjw.com&kwgp=2" frameBorder=0 width=280 scrolling=no height=90>
</IFRAME>
</div>
posted @ 2009-12-22 08:57 kenryuu 阅读(123) 评论(0) 编辑

 

//上传      

protected void Button1_Click(object sender, EventArgs e)
        {
            if (FileUpload1.HasFile)
            {
                string fileContentType = FileUpload1.PostedFile.ContentType;
                if (fileContentType == "image/bmp" || fileContentType == "image/gif" || fileContentType == "image/pjpeg")
                {
                    string name = FileUpload1.PostedFile.FileName;                  // 客户端文件路径

                    FileInfo file = new FileInfo(name);
                    string fileName = file.Name;                                    // 文件名称
                    string fileName_s = "x_" + file.Name;                           // 缩略图文件名称
                    string fileName_sy = "text_" + file.Name;                         // 水印图文件名称(文字)
                    string fileName_syp = "water_" + file.Name;                       // 水印图文件名称(图片)
                    string webFilePath = Server.MapPath("ImgUpload/" + fileName);        // 服务器端文件路径
                    string webFilePath_s = Server.MapPath("ImgUpload/" + fileName_s);  // 服务器端缩略图路径
                    string webFilePath_sy = Server.MapPath("ImgUpload/" + fileName_sy); // 服务器端带水印图路径(文字)
                    string webFilePath_syp = Server.MapPath("ImgUpload/" + fileName_syp); // 服务器端带水印图路径(图片)
                    string webFilePath_sypf = Server.MapPath("test.png"); // 服务器端水印图路径(图片)

                    if (!File.Exists(webFilePath))
                    {
                        try
                        {
                            FileUpload1.SaveAs(webFilePath);                                // 使用 SaveAs 方法保存文件
                            AddWater(webFilePath, webFilePath_sy);
                            AddWaterPic(webFilePath, webFilePath_syp, webFilePath_sypf);
                            MakeThumbnail(webFilePath, webFilePath_s, 130, 130, "Cut");     // 生成缩略图方法
                            Label1.Text = "提示:文件“" + fileName + "”成功上传,并生成“" + fileName_s + "”缩略图,文件类型为:" + FileUpload1.PostedFile.ContentType + ",文件大小为:" + FileUpload1.PostedFile.ContentLength + "B";
                        }
                        catch (Exception ex)
                        {
                            Label1.Text = "提示:文件上传失败,失败原因:" + ex.Message;
                        }
                    }
                    else
                    {
                        Label1.Text = "提示:文件已经存在,请重命名后上传";
                    }
                }
                else
                {
                    Label1.Text = "提示:文件类型不符";
                }
            }
        }
        /**/
        /// <summary>
        /// 生成缩略图
        /// </summary>
        /// <param name="originalImagePath">源图路径(物理路径)</param>
        /// <param name="thumbnailPath">缩略图路径(物理路径)</param>
        /// <param name="width">缩略图宽度</param>
        /// <param name="height">缩略图高度</param>
        /// <param name="mode">生成缩略图的方式</param>   
        public static void MakeThumbnail(string originalImagePath, string thumbnailPath, int width, int height, string mode)
        {
            System.Drawing.Image originalImage = System.Drawing.Image.FromFile(originalImagePath);

            int towidth = width;
            int toheight = height;

            int x = 0;
            int y = 0;
            int ow = originalImage.Width;
            int oh = originalImage.Height;

            switch (mode)
            {
                case "HW"://指定高宽缩放(可能变形)               
                    break;
                case "W"://指定宽,高按比例                   
                    toheight = originalImage.Height * width / originalImage.Width;
                    break;
                case "H"://指定高,宽按比例
                    towidth = originalImage.Width * height / originalImage.Height;
                    break;
                case "Cut"://指定高宽裁减(不变形)               
                    if ((double)originalImage.Width / (double)originalImage.Height > (double)towidth / (double)toheight)
                    {
                        oh = originalImage.Height;
                        ow = originalImage.Height * towidth / toheight;
                        y = 0;
                        x = (originalImage.Width - ow) / 2;
                    }
                    else
                    {
                        ow = originalImage.Width;
                        oh = originalImage.Width * height / towidth;
                        x = 0;
                        y = (originalImage.Height - oh) / 2;
                    }
                    break;
                default:
                    break;
            }

            //新建一个bmp图片
            System.Drawing.Image bitmap = new System.Drawing.Bitmap(towidth, toheight);

            //新建一个画板
            System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap);

            //设置高质量插值法
            g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;

            //设置高质量,低速度呈现平滑程度
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

            //清空画布并以透明背景色填充
            g.Clear(System.Drawing.Color.Transparent);

            //在指定位置并且按指定大小绘制原图片的指定部分
            g.DrawImage(originalImage, new System.Drawing.Rectangle(0, 0, towidth, toheight),
                new System.Drawing.Rectangle(x, y, ow, oh),
                System.Drawing.GraphicsUnit.Pixel);

            try
            {
                //以jpg格式保存缩略图
                bitmap.Save(thumbnailPath, System.Drawing.Imaging.ImageFormat.Jpeg);
            }
            catch (System.Exception e)
            {
                throw e;
            }
            finally
            {
                originalImage.Dispose();
                bitmap.Dispose();
                g.Dispose();
            }
        }

        /**/
        /// <summary>
        /// 在图片上增加文字水印
        /// </summary>
        /// <param name="Path">原服务器图片路径</param>
        /// <param name="Path_sy">生成的带文字水印的图片路径</param>
        protected void AddWater(string Path, string Path_sy)
        {
            string addText = "中国";
            System.Drawing.Image image = System.Drawing.Image.FromFile(Path);
            System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(image);
            g.DrawImage(image, 0, 0, image.Width, image.Height);
            System.Drawing.Font f = new System.Drawing.Font("Verdana", 60);
            System.Drawing.Brush b = new System.Drawing.SolidBrush(System.Drawing.Color.Green);

            g.DrawString(addText, f, b, 35, 35);
            g.Dispose();

            image.Save(Path_sy);
            image.Dispose();
        }

        /**/
        /// <summary>
        /// 在图片上生成图片水印
        /// </summary>
        /// <param name="Path">原服务器图片路径</param>
        /// <param name="Path_syp">生成的带图片水印的图片路径</param>
        /// <param name="Path_sypf">水印图片路径</param>
        protected void AddWaterPic(string Path, string Path_syp, string Path_sypf)
        {
            System.Drawing.Image image = System.Drawing.Image.FromFile(Path);
            System.Drawing.Image copyImage = System.Drawing.Image.FromFile(Path_sypf);
            System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(image);
            g.DrawImage(copyImage, new System.Drawing.Rectangle(image.Width - copyImage.Width, image.Height - copyImage.Height, copyImage.Width, copyImage.Height), 0, 0, copyImage.Width, copyImage.Height, System.Drawing.GraphicsUnit.Pixel);
            g.Dispose();

            image.Save(Path_syp);
            image.Dispose();
        }

posted @ 2009-11-11 10:11 kenryuu 阅读(1806) 评论(0) 编辑

在JS中使用window.close();时经常会遇到这样的提示“你查看的网页正试图关闭窗口,是否关闭。”,这实际上是IE的安全特性的一项内容,是不能通过设置浏览器加以解决的。要将窗口关闭提示消息屏蔽,需要增加额外的代码。

在IE6中,可以通过在close之前设置窗体的opener属性值得以解决,范例代码如下:
window.opener="xxx";
window.close();

在IE7,IE8中,上述的代码并无法奏效,此时需要重载window.close()函数解决该问题,范例代码如下:
var closeWinFunc = window.close;
window.close = function(){
  window.open("","_self");
  closeWinFunc();
}
window.close();

posted @ 2009-09-01 16:19 kenryuu 阅读(588) 评论(0) 编辑
ASP.net 中Gridview控件没有单击处理,代替单击处理,以下两种方法可以处理。
(1)用SelectedIndexChanged事件
HTML Code
<asp:CommandField ButtonType="Button" HeaderText="添加" ShowHeader="True" SelectText="Add" ShowSelectButton="True">
                
<HeaderStyle Width="1%" Wrap="False" />
                
<ItemStyle HorizontalAlign="Center" />
      
</asp:CommandField>

C# Code
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
         //相关处理

    }


(2)在databound里添加行的js脚本,实现跳转。

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowIndex != -1)
        {
            e.Row.Attributes.Add("onclick", "Url('" + this.GridView1.DataKeys[e.Row.RowIndex].Value.ToString().Trim() + "')");
        }
    }


posted @ 2009-09-01 16:13 kenryuu 阅读(93) 评论(0) 编辑
仅列出标题