如何在ASP.NET页面中自动生成并显示透明的GIF图片
在页面中加入一个图片控件,并将它的Style属性设为:FILTER: chroma(color:#000000) ,原因是自动生成的GIF图片总是黑色背景。然后在后台代码中写入如下代码。(见DEMO)
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Drawing.Drawing2D;
namespace WebPageIndex
{
/**//// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.HtmlControls.HtmlImage IMG1;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
MyTempImage myTempImage=new MyTempImage();
IMG1.Src=myTempImage.CreateImage();
}
public class MyTempImage : Page
{
public string CreateImage()
{
string str="兴中公司财务章";
Bitmap image=new Bitmap(300,300);
Graphics g=Graphics.fromImage(image);
string thefullname=Server.MapPath("/")+"\\nowtime.gif";
Pen p=new Pen(Brushes.Red,10);
Pen p1=new Pen(Brushes.Red,5);
SolidBrush b=new SolidBrush(Color.Red);
g.SmoothingMode=SmoothingMode.AntiAlias;
Point point1 = new Point( 150, 50);
Point point2 = new Point(50, 150);
Point point3 = new Point(230, 150);
Point[] curvePoints =
{
point1,
point2,
point3,
};
g.FillPolygon(b,curvePoints,FillMode.Winding );
g.DrawEllipse(p,10,10,280,280);
g.DrawString(str,new Font("隶书",20,FontStyle.Bold),new
SolidBrush(Color.fromArgb(255, 255,0
相关文档:
在部署水晶报表时主要遇到支持组件的问题。
首先,需要在服务器上需要安装“CRRedist2008_x86.msi”和汉化包“CRRedist2008_x86_chs.msi”。
vs.net 2008,在这个目录
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\CrystalReports10_5
vs.net 2005,在这个目录
C:\Progr ......
页面导出Excel时,常用的直接RenderControl的方法,如果表格中有数字,在Excel中往往格式会乱,比如前面有0,但显示出来后0都被去掉了。
因此要在绑定数字的时候,手动指定一下此列的格式,让数字以文本方式显示就行了
protected void myGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
......
方案一:
/**//// <summary>
/// 名称:IsNumberic
/// 功能:判断输入的是否是数字
/// 参数:string oText:源文本
/// 返回值: bool true:是 false:否
/// </summary>
public bool IsNumberic(string oText)
{
try
{
int var1=Convert.ToInt32 (oText);
return true;
}
catch ......
'<%#Eval("djid").ToString()+Eval("djid1").ToString()+… %>'这种形式就行
把Eval("").ToString()当成一个普通字符串,而'<%# %>'保留就行,怎么处理都可以,所有字符串的操作都有效,还可以用静态函数来处理这些字符串。 ......