Doubts using Ext.MessageBox - Ext JS

本文讨论了如何在ExtJS中正确显示来自服务器的错误信息,特别是当错误信息包含大量HTML内容时的处理方法。作者尝试使用Ext.MessageBox显示这些信息,但遇到了按钮被长文本遮挡的问题。文中探讨了通过iframe展示完整HTML页面的解决方案。
Hi I would like to show the error from server in a Ext.MessageBox but I don't know how I can fill the textArea using multiline, a liltle help please.

Using Ext.MessageBox.alert('Status', resp.responseText); appear the error but I can't close this windows becouse the error text is big and the close button disapear.



I am doing it:

function responseFailure(resp){
//alert(resp.responseText);
//debugger;
//Ext.MessageBox.alert('Status', resp.responseText);
Ext.MessageBox.show({
title: 'Error',
msg: 'Please send it support:',
width:300,
buttons: Ext.MessageBox.OK,
multiline: true,
textboxEl: resp.responseText

});
}

kind regards
Frank
Reply With Quote
  #2  
Old 03-01-2007, 09:28 PM
Default

Using alpha2 rev6, I'm unable to reproduce this problem. Which one are you using?
Reply With Quote
  #3  
Old 03-02-2007, 07:32 AM
Default

Yes I am using alpha2 rev6, when I get a error from server (asp.net) it response with an aspx page, in my case I get the error from server in resp.responseText, it appear in the Ext.MessageBox.alert with yellow color in error ect.. like appear in an aspx page with error, but it has many text and disapear the close button, I would like show the error inside textArea in a multi-line prompt dialog, becouse it have scroll bar but I don't know how set the resp.responseText to textArea inside multi-line prompt dialog, I like the alert becouse it show the resp.responseText with color (like a html page), but don't have scroll bar and only has a button OK. Is there some dialog where I can show the error with scroll, and add for instance a button to send error for mail I mean (show the error and appear Send Error button)?

kind regards
Frank
Reply With Quote
  #4  
Old 03-02-2007, 07:39 AM
Default

Setting HTML inside a textarea will have the effect that the HTML is not shown rendered anymore. You better put the ASP error inside a div element, and then set the css property overflow:auto, so it will have a scrollbar.

Could you post a screenshot BTW, your description of the problem is very unclear.
Reply With Quote
  #5  
Old 03-02-2007, 02:02 PM
Default

Quote:
Originally Posted by franklt69
Yes I am using alpha2 rev6, when I get a error from server (asp.net) it response with an aspx page, in my case I get the error from server in resp.responseText, it appear in the Ext.MessageBox.alert with yellow color in error ect.. like appear in an aspx page with error, but it has many text and disapear the close button,[...]
Well, I guess the question then, is how much text are you getting back? Can that text be paired down to the bare essentials? And, is that text an entire HTML document with doctype, html tag, head tag, body tag, etc? If so, that's just not going to work like you want it to. In order to include it in the dialog, it must be an HTML fragment, not a complete HTML document.
Reply With Quote
  #6  
Old 03-02-2007, 05:45 PM
Default

more clear , I am doing it:

I send a xml to server, I parsed it and update the database, if there is an error in this proccess I catch the exception and send it to client, then I want to show it to user, but if I try with alert the exception from server has many information and the button close in the dialog go up and don't appear in the browse, so the doubt can I use some Ext.MessageBox dialog to show the client or I have to do my dialog?


using a multi-line prompt dialog the error don't appear in html format but i can read it using scroll how I can add the error to textArea in multi-line prompt dialog?

example the a exception send from server



<html><head><title>Object reference not set to an instance of an object.</title>


<style>
body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;}
p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
pre {font-family:"Lucida Console";font-size: .9em}
.marker {font-weight: bold; color: black;text-decoration: none;}
.version {color: gray;}
.error {margin-bottom: 10px;}
.expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }
</style></head><body bgcolor="white">

<span><h1>Server Error in '/ASFA' Application.<hr color="silver" size="1" width="100%"></h1>

<h2> Object reference not set to an instance of an object. </h2></span>

<font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.





Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.



Source Error:



<table bgcolor="#ffffcc" width="100%">
<tbody><tr>
<td>
<code></code><pre>
Line 42: public XmlToDb(string Id )
Line 43: {
<font color="red">Line 44: Attributes.Add("throw an error");
</font>Line 45: Attributes = new ArrayList();
Line 46: Values = new ArrayList();</pre>

</td>
</tr>

</tbody></table>




Source File: c:\projectest\WebSite\XmlToDb\XmlToDb.cs Line: 44




Stack Trace:



<table bgcolor="#ffffcc" width="100%">
<tbody><tr>
<td>
<code></code><pre>
[NullReferenceException: Object reference not set to an instance of an object.]
WebSite.XmlToDb..ctor(String Id) in c:\projectest\WebSite\XmlToDb\XmlToDb.cs:44
WebSite.HandlerXmlToDb.ProcessRequest(HttpContext context) in c:\projectest\WebSite\XmlToDb\HandlerXmlToDb.ashx.cs:67
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute() +179
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +87

</pre>

</td>
</tr>
</tbody></table>




<hr color="silver" size="1" width="100%">

Version Information:Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032

</font>

<!--
[NullReferenceException]: Object reference not set to an instance of an object.
atWebSite.XmlToDb..ctor(String Id) in c:\projectest\WebSite\XmlToDb\XmlToDb.cs:line 44
atWebSite.HandlerXmlToDb.ProcessRequest(HttpContext context) in c:\projectest\WebSite\XmlToDb\HandlerXmlToDb.ashx.cs:line 67
at System.Web.CallHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
--></body></html>

kind regards
Frank
Reply With Quote
  #7  
Old 03-02-2007, 06:37 PM
Default

If you are getting back a full HTML page as the response, try displaying it in an iframe. If you inject XML containing an HTML element into a subelement of your page it can really confuse your browser.
Reply With Quote
  #8  
Old 03-02-2007, 08:34 PM
Default

Alright franklt69, I need you to go back and reread my previous reply. I specifically said that you weren't going to get things to work properly if you are injecting HTML that contains a doctype, html tag, head tag, or body tag into your dialog.

Rather than an alert, you're going to have to take that build a basic dialog with an iframe, take the response from the server, and inject that into the iframe's DOM.

What might be easier is trimming down the response the server sends to something that's just an HTML fragment.
Reply With Quote
  #9  
Old 03-07-2007, 08:20 AM
Default

Hi I need some help about how inject html into a Iframe


when in the server (asp.net) there is an error it response with a html like the code post above, then I am doing it

function responseFailure(resp){

showError(resp.responseText);

}


showError: function(aError){
if(!dlgError){ // lazy initialize the dialog and only create it once
dlgError = new Ext.LayoutDialog("dlg-error", {
modal:true,
width:800,
height:400,
shadow:true,
minWidth:300,
minHeight:300,
proxyDrag:true,
title: 'Error Windows',
shadow:true,
center:{alwaysShowTabs:true},
north: {
split:false,
initialSize: 25

},

center: {
autoScroll:true,
tabPosition: 'top',
closeOnTab: true,
alwaysShowTabs: false
}
});
dlgError.addKeyListener(27, dlgError.hide, dlgError);
dlgError.addButton('Send', dlgError.hide, dlgError);
dlgError.addButton('Dont Send', dlgError.hide, dlgError);

var layout = dlgError.getLayout();
dlgError.beginUpdate();
debugger;
var iframe = Ext.DomHelper.append(document.body,
{tag: 'iframe', frameBorder: 0});
iframe.innerHTML = aError;
feedPanel = new Ext.ContentPanel(iframe, {fitToFrame:true, autoScroll:true, closable:false});
layout.add('center', feedPanel);
dlgError.endUpdate();
}

dlgError.show();
}


the doubt is how I can inject the html (aError) into an iframe ?

kind regards
Frank
Reply With Quote
  #10  
Old 03-07-2007, 10:34 AM
Default

Why are you allowing the server exception to just dump back to a generic error page? You should catch the exception in your aspx page and build a simple reponse string from the exception properties (e.g. Message, Stacktrace, InnerException, etc). Then pass that back without all the html and use that as the content of your dialog body. The way you're doing it now, it appears that the error is not being caught and just output via the standard .Net error page.
__________________
Tim Ryan - Ext JS Support Team
Read BEFORE posting a question / posting a Bug
Use Google to Search - API / Forum
API Doc (3.x | 2.x | 1.x) / FAQ / Wiki / Tutorials / 1.x->2.0 Migration Guide
Reply With Quote
内容概要:本文介绍了一个基于Matlab的综合能源系统优化调度仿真资源,重点实现了含光热电站、有机朗肯循环(ORC)和电含光热电站、有机有机朗肯循环、P2G的综合能源优化调度(Matlab代码实现)转气(P2G)技术的冷、热、电多能互补系统的优化调度模型。该模型充分考虑多种能源形式的协同转换与利用,通过Matlab代码构建系统架构、设定约束条件并求解优化目标,旨在提升综合能源系统的运行效率与经济性,同时兼顾灵活性供需不确定性下的储能优化配置问题。文中还提到了相关仿真技术支持,如YALMIP工具包的应用,适用于复杂能源系统的建模与求解。; 适合人群:具备一定Matlab编程基础和能源系统背景知识的科研人员、研究生及工程技术人员,尤其适合从事综合能源系统、可再生能源利用、电力系统优化等方向的研究者。; 使用场景及目标:①研究含光热、ORC和P2G的多能系统协调调度机制;②开展考虑不确定性的储能优化配置与经济调度仿真;③学习Matlab在能源系统优化中的建模与求解方法,复现高水平论文(如EI期刊)中的算法案例。; 阅读建议:建议读者结合文档提供的网盘资源,下载完整代码和案例文件,按照目录顺序逐步学习,重点关注模型构建逻辑、约束设置与求解器调用方式,并通过修改参数进行仿真实验,加深对综合能源系统优化调度的理解。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值