| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 855 人关注过本帖
标题:用户自定控件中的属性定义问题
取消只看楼主 加入收藏
ycbbg
Rank: 1
来 自:江西
等 级:新手上路
帖 子:99
专家分:0
注 册:2007-11-26
结帖率:100%
收藏
 问题点数:0 回复次数:2 
用户自定控件中的属性定义问题
我做了段用户自定控件代码:

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

public partial class controls_upload : System.Web.UI.UserControl
{
   
    //upimg_method属性值为:img或warter;
   
    public string upimg_method;
    public string Upimg_method
    {
        set
        {
            this.upimg_method = value.ToString();
        }
        
    }


    public string textBox_path
    {
        set
        {
            this.TextBox_img.Text = value.ToString();
        }
        get
        {
          return   this.TextBox_img.Text;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (this.upimg_method == "warter")
        {
            upimg_warter();
        }
        //if (this.upimg_method== "img")
        else
        {
            upimg_img();
        }
    }

    public void upimg_warter()
    {
        UP_img up_img = new UP_img();
        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 = "w_" + file.Name;                            // 水印图文件名称(图片)
                string webFilePath = Server.MapPath("/test/ImgUpload") + "/" + fileName;          // 服务器端文件路径
                string webFilePath_s = Server.MapPath("/test/ImgUpload") + "/S_" + fileName;    // 服务器端缩略图路径
                //string webFilePath_sy = Server.MapPath("ImgUpload/" + fileName_sy);   // 服务器端带水印图路径(文字)
                string webFilePath_syp = Server.MapPath("/test/ImgUpload") + "/W_" + fileName; // 服务器端带水印图路径(图片)
                string webFilePath_sypf = Server.MapPath("/test/ImgUpload") + "/water.png";                // 服务器端水印图路径(图片)
                /*
                string webFilePath = Server.MapPath("../ImgUpload/" + fileName);          // 服务器端文件路径
                string webFilePath_s = Server.MapPath("../ImgUpload/S_" + fileName);    // 服务器端缩略图路径
                //string webFilePath_sy = Server.MapPath("ImgUpload/" + fileName_sy);   // 服务器端带水印图路径(文字)
                string webFilePath_syp = Server.MapPath("../ImgUpload/W_" + fileName); // 服务器端带水印图路径(图片)
                string webFilePath_sypf = Server.MapPath("../ImgUpload/water.png");                // 服务器端水印图路径(图片)
                 */
                try
                {
                    FileUpload1.SaveAs(webFilePath);                                   // 使用 SaveAs 方法保存文件
                    //AddWater(webFilePath, webFilePath_sy);
                    up_img.AddWaterPic(webFilePath, webFilePath_syp, webFilePath_sypf);
                    //up_img.MakeThumbnail(webFilePath, webFilePath_s, 130, 130, "W");          // 生成缩略图方法
                    Label1.Text = "文件上传成功!";
                    TextBox_img.Text = fileName;

                    (webFilePath);
                }
                catch (Exception ex)
                {
                    Response.Write("文件上传失败!");
                }
            }
            else
            {
                Response.Write("文件类型不符!");
            }
        }
    }

    public void upimg_img()
    {
        UP_img up_img = new UP_img();
        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 = "w_" + file.Name;                            // 水印图文件名称(图片)
                string webFilePath = Server.MapPath("/test/ImgUpload") + "/" + fileName;          // 服务器端文件路径
             string webFilePath_s = Server.MapPath("/test/ImgUpload") + "/S_" + fileName;    // 服务器端缩略图路径
                //string webFilePath_sy = Server.MapPath("ImgUpload/" + fileName_sy);   // 服务器端带水印图路径(文字)
                //string webFilePath_syp = Server.MapPath("/test/ImgUpload") + "/W_" + fileName; // 服务器端带水印图路径(图片)
                //string webFilePath_sypf = Server.MapPath("/test/ImgUpload") + "/water.png";                // 服务器端水印图路径(图片)
                /*
                string webFilePath = Server.MapPath("../ImgUpload/" + fileName);          // 服务器端文件路径
                string webFilePath_s = Server.MapPath("../ImgUpload/S_" + fileName);    // 服务器端缩略图路径
                //string webFilePath_sy = Server.MapPath("ImgUpload/" + fileName_sy);   // 服务器端带水印图路径(文字)
                string webFilePath_syp = Server.MapPath("../ImgUpload/W_" + fileName); // 服务器端带水印图路径(图片)
                string webFilePath_sypf = Server.MapPath("../ImgUpload/water.png");                // 服务器端水印图路径(图片)
                 */
                try
                {
                    FileUpload1.SaveAs(webFilePath);                                   // 使用 SaveAs 方法保存文件
                    //AddWater(webFilePath, webFilePath_sy);
                    //up_img.AddWaterPic(webFilePath, webFilePath_syp, webFilePath_sypf);
                   up_img.MakeThumbnail(webFilePath, webFilePath_s, 130, 130, "W");          // 生成缩略图方法
                    Label1.Text = "文件上传成功!";
                    TextBox_img.Text = fileName;

                    (webFilePath);
                }
                catch (Exception ex)
                {
                    Response.Write("文件上传失败!");
                }
            }
            else
            {
                Response.Write("文件类型不符!");
            }
        }

    }
}


问题是:

在调用此控件时<uc1:upload id="Upload1"   Upimg_method="img"  runat="server"> </uc1:upload>

Upimg_method属性的值如果要下拉列出该如何处理
搜索更多相关主题的帖子: 控件 定义 属性 用户 
2008-08-26 15:19
ycbbg
Rank: 1
来 自:江西
等 级:新手上路
帖 子:99
专家分:0
注 册:2007-11-26
收藏
得分:0 
请高手帮帮忙

http://www.
2008-08-26 15:19
ycbbg
Rank: 1
来 自:江西
等 级:新手上路
帖 子:99
专家分:0
注 册:2007-11-26
收藏
得分:0 
有知道的吗

http://www.
2008-08-29 15:29
快速回复:用户自定控件中的属性定义问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.056482 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved