用户自定控件中的属性定义问题
我做了段用户自定控件代码: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属性的值如果要下拉列出该如何处理