首先,您的按钮是控件来的,随非您将DIv也加入runat="server"
,把DIV显示出来,不过,这种方式,一般都不行,因为,当你把DIV显示出来了,那button按钮就会刷新页面一次,DIV也不会显示出来了。
您可以对button按钮加入OnClientClick事件,写JS显示出来。
我晕~~~~~~ js文件是运行在前台的文件,你在后台怎么可能产生js文件?下面是在后台代码中生成的随机数字验证码
/// <summary>
/// 生成一个验证码
/// </summary>
using System.Drawing
using System.Drawing.Imaging
private void CreateValidateCode()
{
using(Bitmap bitmap = new Bitmap(80, 24))
{
using(Graphics g = Graphics.FromImage(bitmap))
{
Random rand = new Random()
int code = rand.Next(1000, 9999)
string strcode = code.ToString()
g.DrawString(strcode, new Font("宋体", 18), Brushes.Red, 10, 0)
Session["ValidateCode"] = strcode//使用Session保存数字验证码
ImageButton1.ImageUrl = "source/1.jpg" // 使用source文件夹下面的图片 1.jpg
}
string abspath = System.Web.HttpContext.Current.Server.MapPath(@"source/1.jpg")// 使用source文件夹下面的图片 1.jpg, 作为输出内存中的图片的载体
bitmap.Save(abspath, ImageFormat.Jpeg)
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)