![]() |
#2
cxherocx2010-10-19 19:17
我把具体代码放到这里,大家看看
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <%@ Import Namespace = "System.Drawing" %> <%@ Import Namespace = "System.Drawing.Imaging" %> <%@ Import Namespace = "System.Drawing.Drawing2D" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www. <script runat="server"> protected void Page_Load(object sender, EventArgs e) { // Create a font style. Font rectangleFont = new Font( "Arial", 10, FontStyle.Bold); // Create integer variables. int height = 100; int width = 200; // Create a bitmap and use it to create a // Graphics object. Bitmap bmp = new Bitmap( width, height, PixelFormat.Format24bppRgb); Graphics g = Graphics.FromImage(bmp); g.SmoothingMode = SmoothingMode.AntiAlias; g.Clear(Color.LightGray); // Use the Graphics object to draw three rectangles. g.DrawRectangle(Pens.White, 1, 1, width - 3, height - 3); g.DrawRectangle(Pens.Aquamarine, 2, 2, width - 3, height - 3); g.DrawRectangle(Pens.Black, 0, 0, width, height); // Use the Graphics object to write a string // on the rectangles. g.DrawString( " Samples", rectangleFont, SystemBrushes.WindowText, new PointF(10, 40)); // Save the bitmap to the response stream and // convert it to JPEG format. bmp.Save(Response.OutputStream, ImageFormat.Jpeg); // Release memory used by the Graphics object // and the bitmap. g.Dispose(); bmp.Dispose(); } </script> <html xmlns="http://www. > <head id="Head1" runat="server"> <title>CheckBox Control</title> </head> <body> <form id="form1" runat="server"> <div> <h1>CheckBox Control</h1> <asp:Label ID="lblTime" runat="server" OnInit="lblTime_Init" /> <br /> <br /> <asp:CheckBox ID="chkUnderLine" runat="server" AutoPostBack="True" Text="Underline?" TextAlign="Left" OnCheckedChanged="chkUnderLine_CheckedChanged" /> <asp:CheckBox ID="chkOverLine" runat="server" AutoPostBack="True" Text="Overline?" OnCheckedChanged="chkOverLine_CheckedChanged" /> <asp:CheckBox ID="chkStrikeout" runat="server" AutoPostBack="True" Text="Strikeout?" OnCheckedChanged="chkStrikeout_CheckedChanged" /> </div> </form> </body> </html> 这个代码中的 CheckBox都不可见了,怎么回事? |
我在隐藏文件cs中的Page_Load函数中 如下,定义画图行为,
protected void Page_Load(object sender, EventArgs e)
{
Bitmap bmp = new Bitmap(
width, height, PixelFormat.Format24bppRgb);
Graphics g = Graphics.FromImage(bmp);
// Save the bitmap to the response stream and
// convert it to JPEG format.
bmp.Save(Response.OutputStream, ImageFormat.Jpeg);
// Release memory used by the Graphics object
// and the bitmap.
g.Dispose();
bmp.Dispose();
}
当函数Page_Load 执行后,aspx文件中定义的其他控件都不可见了,我查找后 发现如果将 bmp.Save(Response.OutputStream, ImageFormat.Jpeg)注释后,aspx文件中定义的其他控件 可以操作了,这是为什么,是不是和Response.OutputStream 有关,请大侠赐教!!