框架中的left页面通过
window.parent.document.getElementById("right").src="right.aspx?imageUrl="+get_listBox_selection();
传递参数给框架中的right.aspx页面
public partial class right : System.Web.UI.Page
{
string filename;
protected void Page_Load(object sender, EventArgs e)
{
string getString=Request["imageUrl"];
if(Request["imageUrl"]==null || Request["imageUrl"]=="")return;
//string filename;
filename = getString.Replace('\\', '_').Substring(8,(getString.Length-12));
DrawPicture(getString,filename);
}
void DrawPicture(string sourcefile, string filename)
{
Process micapsProcess = new Process();
micapsProcess.StartInfo.FileName = @"C:\MICAPS3\micaps3.exe";
micapsProcess.StartInfo.Arguments = sourcefile + " "+HttpRuntime.AppDomainAppPath+@"\temppic\"+filename+".png";
//sourcefile 要画图的数据文件,
//HttpRuntime.AppDomainAppPath+@"\temppic\"+filename+".png 生成图文件的绝对路径和文件名
micapsProcess.EnableRaisingEvents = true;
micapsProcess.Exited+=new EventHandler(micapsProcess_Exited);
micapsProcess.Start();
ImageMap1.ImageUrl = @"~/temppic/" + filename + ".png";
//把这张图连接显示
}
void micapsProcess_Exited(object sender, System.EventArgs e)
{
ImageMap1.ImageUrl = @"~/temppic/" + filename + ".png";
this.Response.Write("aaa");
}
}问题是:1、生成图需要一点时间,在图还没有生成完已经执行了ImageMap1.ImageUrl = @"~/temppic/" + filename + ".png";所以图不能显示出来,不知道如何解决
2、想在进程退出事件中micapsProcess_Exited执行ImageMap1.ImageUrl = @"~/temppic/" + filename ,但也没有成功。
同时这一句this.Response.Write("aaa")出现这样的错:
未处理 System.Web.HttpException
Message="响应在此上下文中不可用。"
Source="System.Web"
ErrorCode=-2147467259
StackTrace:
在 System.Web.UI.Page.get_Response()
在 right.micapsProcess_Exited(Object sender, EventArgs e) 位置 h:\WeatherWebSite\Web\right.aspx.cs:行号 46
在 System.Diagnostics.Process.OnExited()
在 System.Diagnostics.Process.RaiseOnExited()
在 System.Diagnostics.Process.CompletionCallback(Object context, Boolean wasSignaled)
在 System.Threading._ThreadPoolWaitOrTimerCallback.WaitOrTimerCallback_Context(Object state, Boolean timedOut)
在 System.Threading._ThreadPoolWaitOrTimerCallback.WaitOrTimerCallback_Context_f(Object state)
在 System.Threading.ExecutionContext.runTryCode(Object userData)
在 System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading._ThreadPoolWaitOrTimerCallback.PerformWaitOrTimerCallback(Object state, Boolean timedOut)
InnerException:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
已经发了两个贴了
http://topic.csdn.net/u/20100408/14/50542ef5-0f36-4bd0-9c1b-dd603869b3a2.html
http://topic.csdn.net/u/20100409/09/76bb14ab-5dae-4672-9c85-bf906a4bfbc4.html
请大哥大姐们帮个忙
顺便来这个两个贴,把分领了
window.parent.document.getElementById("right").src="right.aspx?imageUrl="+get_listBox_selection();
传递参数给框架中的right.aspx页面
public partial class right : System.Web.UI.Page
{
string filename;
protected void Page_Load(object sender, EventArgs e)
{
string getString=Request["imageUrl"];
if(Request["imageUrl"]==null || Request["imageUrl"]=="")return;
//string filename;
filename = getString.Replace('\\', '_').Substring(8,(getString.Length-12));
DrawPicture(getString,filename);
}
void DrawPicture(string sourcefile, string filename)
{
Process micapsProcess = new Process();
micapsProcess.StartInfo.FileName = @"C:\MICAPS3\micaps3.exe";
micapsProcess.StartInfo.Arguments = sourcefile + " "+HttpRuntime.AppDomainAppPath+@"\temppic\"+filename+".png";
//sourcefile 要画图的数据文件,
//HttpRuntime.AppDomainAppPath+@"\temppic\"+filename+".png 生成图文件的绝对路径和文件名
micapsProcess.EnableRaisingEvents = true;
micapsProcess.Exited+=new EventHandler(micapsProcess_Exited);
micapsProcess.Start();
ImageMap1.ImageUrl = @"~/temppic/" + filename + ".png";
//把这张图连接显示
}
void micapsProcess_Exited(object sender, System.EventArgs e)
{
ImageMap1.ImageUrl = @"~/temppic/" + filename + ".png";
this.Response.Write("aaa");
}
}问题是:1、生成图需要一点时间,在图还没有生成完已经执行了ImageMap1.ImageUrl = @"~/temppic/" + filename + ".png";所以图不能显示出来,不知道如何解决
2、想在进程退出事件中micapsProcess_Exited执行ImageMap1.ImageUrl = @"~/temppic/" + filename ,但也没有成功。
同时这一句this.Response.Write("aaa")出现这样的错:
未处理 System.Web.HttpException
Message="响应在此上下文中不可用。"
Source="System.Web"
ErrorCode=-2147467259
StackTrace:
在 System.Web.UI.Page.get_Response()
在 right.micapsProcess_Exited(Object sender, EventArgs e) 位置 h:\WeatherWebSite\Web\right.aspx.cs:行号 46
在 System.Diagnostics.Process.OnExited()
在 System.Diagnostics.Process.RaiseOnExited()
在 System.Diagnostics.Process.CompletionCallback(Object context, Boolean wasSignaled)
在 System.Threading._ThreadPoolWaitOrTimerCallback.WaitOrTimerCallback_Context(Object state, Boolean timedOut)
在 System.Threading._ThreadPoolWaitOrTimerCallback.WaitOrTimerCallback_Context_f(Object state)
在 System.Threading.ExecutionContext.runTryCode(Object userData)
在 System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading._ThreadPoolWaitOrTimerCallback.PerformWaitOrTimerCallback(Object state, Boolean timedOut)
InnerException:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
已经发了两个贴了
http://topic.csdn.net/u/20100408/14/50542ef5-0f36-4bd0-9c1b-dd603869b3a2.html
http://topic.csdn.net/u/20100409/09/76bb14ab-5dae-4672-9c85-bf906a4bfbc4.html
请大哥大姐们帮个忙
顺便来这个两个贴,把分领了
建一个空页面,后台
imageValue是一个object对象,图片的
MemoryStream memStream = new MemoryStream(((byte[])imageValue));
Bitmap image = new Bitmap(memStream);
this.Response.ClearContent();
this.Response.ContentType = "image/Jpeg";
this.Response.CacheControl = "no-cache";
this.Response.Cache.SetNoStore();
this.Response.AddHeader("P3P", "CP=CAO PSA OUR");
image.Save(Response.OutputStream, ImageFormat.Jpeg);
image.Dispose();
memStream.Dispose();
memStream = null;
image = null;
直接放入Page_load中
然后只需要指定ImageMap1.ImageUrl 到该页面就可以了
但我用的是第三方软件生成图的,该软件是成图格式是这样的micaps.exe sourcefile targetfile
请教如何生成到对象中
@"~/temppic/" + filename
是在调用第三方软件的时候
已经执行了ImageMap1.ImageUrl = @"~/temppic/" + filename + ".png";
@"~/temppic/" + filename 这个应该没有问题,如果图存在能连接成功 是在调用第三方软件的时候,而图还没有出来这个时间已经执行了ImageMap1.ImageUrl = @"~/temppic/" + filename + ".png";
这个软件成图需要一定的时间图最后是有出来的在图还没有出来前
已经执行了ImageMap1.ImageUrl = @"~/temppic/" + filename + ".png";
ImageMap1.ImageUrl = @"~/temppic/" + filename + ".png";
之前加了
System.Threading.Thread.Sleep(5000);
图就能加载了
5000我设置了一个足够长的时间
如何图一生成就,就执行ImageMap1.ImageUrl = @"~/temppic/" + filename + ".png";
线程延时,显示加载进度