对图片进行操作,常用的就是上传及对图片进行裁剪,生成缩略图等
/// <summary>
/// jqueryUpImg 图片上传及裁剪
/// </summary>
public class jqueryUpImg : IHttpHandler
{
private string urlPath = "";
对图片进行操作,常用的就是上传及对图片进行裁剪,生成缩略图等
/// <summary>
/// jqueryUpImg 图片上传及裁剪
/// </summary>
public class jqueryUpImg : IHttpHandler
{
private string urlPath = "";
string name = RequestHelper.GetQueryString("name"); //获取请求中的参数name
string param = RequestHelper.GetString("param");
int check_revert = RequestHelper.GetFormInt("check_revert"); //获取请求中的参数check_revert,并转化为整数
string accept_name = RequestHelper.GetFormString("accept_name");
decimal express_fee = RequestHelper.GetFormDecimal("express_fee", 0);
string userip = RequestHelper.GetIP(); //获取IP地址
int click = RequestHelper.GetInt("click", 0); //读取参数click,如果没有返回0
MessageBox工具类是在.Net中使用的后台弹出层,类似C#里面Winform
MessageBox.Show(this, "弹出内容!");
MessageBox.ShowAndRedirect(this, "操作成功,将跳转到:https://www.zhengdecai.com/!", "https://www.zhengdecai.com/");
MessageBox.ResponseScript(this, "alert('弹出内容')");
public class MatchHelper
{
/// <summary>
/// 正则匹配结果集中的第一个匹配项
/// </summary>
/// <param name="regularString">进行匹配的字符串集</param>
/// <summary>
/// Js操作类
/// </summary>
public class JsHelper
{
#region 页面JS操作
/// <summary>
/// 弹出信息,并跳转指定页面。
/// <summary>
/// Html常用帮助类
/// </summary>
public class HtmlHelper
{
#region 获取页面源代码
/// <summary>
/// 获取网页源代码
前端页面代码:
<div> <asp:Button ID="sBtn6" runat="server" OnClick="sBtn6_Click" Text="ZIP压缩" /> <asp:Button ID="sBtn7" runat="server" OnClick="sBtn7_Click" Text="ZIP解压缩" /></div>
使用C#实例:
前端页面代码:
<input id="fileUpload" type="file" runat="server" visible="false" /> <asp:FileUpload ID="FileUpload1" runat="server" /> <asp:Button ID="sBtn1" runat="server" OnClick="sBtn1_Click" Text="FTP上传" /> <asp:Button ID="sBtn2" runat="server" OnClick="sBtn2_Click" Text="FTP下载" /> <asp:Button ID="sBtn3" runat="server" OnClick="sBtn3_Click" Text="FTP删除" /> <asp:Button ID="sBtn4" runat="server" OnClick="sBtn4_Click" Text="FTP文件读取" /> <asp:Button ID="sBtn5" runat="server" OnClick="sBtn5_Click" Text="FTP操作" />
使用C#实例:
前端页面代码:
<input id="fileUpload" type="file" runat="server" visible="false" /> <asp:FileUpload ID="FileUpload1" runat="server" /> <asp:Button ID="sBtn" runat="server" OnClick="sBtn_Click" Text="上传" Visible="false" />
使用C#实例:
使用实例:
private string urlPath = "";
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
urlPath = Server.MapPath("~/file/");
fileInfo();
}
}
/// <summary>
/// 文件操作
/// </summary>
使用实例:
private string urlPath = "";
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
urlPath = Server.MapPath("~/file/");
encryptInfo();
}
}
/// <summary>
/// 字符串加密解密
/// </summary>
前端页面代码:
<style type="text/css"> #DataList1 { border:solid 1px #ff0000; width:600px;} #GridView1 { border:solid 1px #00ff00; margin-top:10px; width:600px;} .Repeater { border:solid 1px #0000ff; margin-top:5px; width:600px;} </style> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" GridLines="None" UseAccessibleHeader="False" OnRowDataBound="GridView1_RowDataBound"> <Columns> <asp:TemplateField HeaderText="站点"> <ItemTemplate> <asp:Label ID="UserSite" runat="server" Text='<%#Bind("UserSite") %>'></asp:Label> </ItemTemplate> <ItemStyle HorizontalAlign="Center"/> </asp:TemplateField> <asp:BoundField DataField="UserName" HeaderText="姓名" /> <asp:BoundField DataField="UserAge" HeaderText="年龄" /> <asp:BoundField DataField="UserSex" HeaderText="性别" /> </Columns> </asp:GridView>
使用C#实例:
前端页面代码:
<style type="text/css"> #DataList1 { border:solid 1px #ff0000; width:600px;} #GridView1 { border:solid 1px #00ff00; margin-top:10px; width:600px;} .Repeater { border:solid 1px #0000ff; margin-top:5px; width:600px;} </style> <asp:DataList ID="DataList1" runat="server"> <ItemTemplate> <table border="0"> <tr> <td> <%#Eval("UserSite")%> <%#Eval("UserName")%> </td> <td> <%#Eval("UserAge")%> <%#Eval("UserSex")%> </td> </tr> </table> </ItemTemplate> </asp:DataList> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" GridLines="None" UseAccessibleHeader="False" OnRowDataBound="GridView1_RowDataBound"> <Columns> <asp:TemplateField HeaderText="站点"> <ItemTemplate> <asp:Label ID="UserSite" runat="server" Text='<%#Bind("UserSite") %>'></asp:Label> </ItemTemplate> <ItemStyle HorizontalAlign="Center"/> </asp:TemplateField> <asp:BoundField DataField="UserName" HeaderText="姓名" /> <asp:BoundField DataField="UserAge" HeaderText="年龄" /> <asp:BoundField DataField="UserSex" HeaderText="性别" /> </Columns> </asp:GridView> <asp:Repeater ID="Repeater1" runat="server"> <ItemTemplate> <table border="0" class="Repeater"> <tr> <td> <%#Eval("UserSite")%> <%#Eval("UserName")%> </td> <td> <%#Eval("UserAge")%> <%#Eval("UserSex")%> </td> </tr> </table> </ItemTemplate> </asp:Repeater>
使用C#实例:
使用实例:
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { verCodeInfo(); } } /// <summary> /// 验证码生成 /// </summary> private void verCodeInfo() { /*方法1*/ VerCodeHelper v = new VerCodeHelper(); Response.Write("<IMG alt=\"" + "" + "\" src=\"data:image/png;base64," + FileHelper.ImgToBase64String(v.Image) + "\" border=\"0\">"); //固定生成长度的验证码 /*方法1*/ /*方法2*/ string chkCode = VerCodeHelper.MakeCode(5); //根据长度自动生成 MemoryStream ms = VerCodeHelper.CreateCodeImg(chkCode); Response.ClearContent(); Response.ContentType = "image/gif"; Response.BinaryWrite(ms.ToArray()); /*方法2*/ }
类库信息:
使用实例:
private string urlPath = ""; protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { urlPath = Server.MapPath("~/file/"); qrCodeInfo(); } } /// <summary> /// 二维码生成 /// </summary> private void qrCodeInfo() { Response.Write("<IMG alt=\"" + "" + "\" src=\"" + "file/" + QrCodeHelper.getQrCodePath("https://www.zhengdecai.com/", "8", urlPath, "zhengdecai_qr.png") + "\" border=\"0\">" + " "); Response.Write("<IMG alt=\"" + "" + "\" src=\"" + "file/" + QrCodeHelper.getQrCodePath("https://www.zhengdecai.com/", "8", urlPath + "zhengdecai_logo.png", urlPath, "zhengdecai_qr_logo.png") + "\" border=\"0\">" + "<br />"); }
类库信息:
使用实例:
private string urlPath = ""; protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { urlPath = Server.MapPath("~/file/"); barCodeInfo(); } } /// <summary> /// 图标生成 /// </summary> private void barCodeInfo() { Response.Write("<IMG alt=\"" + "" + "\" src=\"" + "file/" + BarCodeHelper.getBarCodePath("www.zhengdecai.com", "Code128B", urlPath, "zhengdecai_bar.jpg") + "\" border=\"0\">" + "<br />"); }
类库信息:
使用实例:
private DataTable dt = new DataTable();
private string urlPath = "";
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
dt = new DataTable();
dt.Columns.Add("UserName");
dt.Columns.Add("UserAge");
dt.Columns.Add("UserSex");
dt.Columns.Add("UserSite");
DataRow dr = dt.NewRow();
dr["UserName"] = "郑德才";
dr["UserAge"] = "27";
dr["UserSex"] = "男";
dr["UserSite"] = "http://www.zhengdecai.com";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["UserName"] = "旺旺";
dr["UserAge"] = "29";
dr["UserSex"] = "女";
dr["UserSite"] = "http://www.zhengdecai.cn";
dt.Rows.Add(dr);
dv = new DataView(dt);
urlPath = Server.MapPath("~/file/");
oWCChartInfo();
}
}
/// <summary>
/// 图标生成
/// </summary>
使用实例:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
flashInfo();
}
}
/// <summary>
/// 创建显示图像的标签
/// </summary>
使用实例:
private User u = new User();
private string urlPath = "";
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
#region 基础数据
u = new User();
u.UserName = "郑德才";
u.UserAge = "27";
u.UserSex = "男";
u.UserSite = "http://www.zhengdecai.com";
urlPath = Server.MapPath("~/file/");
#endregion
sessionInfo();
}
}
/// <summary>
/// Session测试
/// </summary>
使用实例:
private User u = new User();
private string urlPath = "";
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
#region 基础数据
u = new User();
u.UserName = "郑德才";
u.UserAge = "27";
u.UserSex = "男";
u.UserSite = "http://www.zhengdecai.com";
urlPath = Server.MapPath("~/file/");
#endregion
cookieInfo();
}
}
/// <summary>
/// Cookie测试
/// </summary>