修复-只能注册格式正确的脚本标签 [英] Fix- Only properly formatted script tags can be registered
问题描述
我有一个网页,并在其上应用了脚本管理器.在页面加载时,我正在检查某种情况,并从代码中显示一个Javascript ShowModalDialog,它工作正常.
I am having a web page and i applied script manager on it. On the page load i am checking some condition and showing a Javascript ShowModalDialog from code and it is working fine.
int isAnyNonProdTaskActive = _nonProduction.IsAnyTaskActive(UserIDFromDB);
if (isAnyNonProdTaskActive > 0)
{
//Displays and Logs Message
_loggerDetails.LogMessage = "EmployeeQuotient.Production.Page_Load() One NonProduction incomplete task found, NonProductionTimeEntryID : " + isAnyNonProdTaskActive.ToString();
_writeLog.LogDetails(_loggerDetails.LogLevel_Info, _loggerDetails.LogMessage);
Session["TaskActiveNonProd"] = isAnyNonProdTaskActive;
Page page = HttpContext.Current.CurrentHandler as Page;
//Displays and Logs Message
_loggerDetails.LogMessage = "EmployeeQuotient.Production.Page_Load() Opening ElapsedClockNonProd.aspx to complete the incomplete task id :" + isAnyNonProdTaskActive.ToString();
_writeLog.LogDetails(_loggerDetails.LogLevel_Info, _loggerDetails.LogMessage);
ScriptManager.RegisterStartupScript(page, page.GetType(), "OpenModalDialog", "<script type=text/javascript>window.showModalDialog('ElapsedClockNonProd.aspx?code=" + isAnyNonProdTaskActive.ToString() + "', null, 'unadorned:yes ;resizable:0 ;dialogWidth:300px ;dialogHeight:300px ;status:no ;scroll:no ;status=no;'); </script>", false);
}
我在同一页面上的按钮上应用了相同的代码,然后出现错误.错误消息是:-Microsoft JScript运行时错误:Sys.WebForms.PageRequestManagerServerErrorException:为类型``ASP.associates_production_aspx''注册的脚本标记和键``OpenModalDialog''在脚本标签之外具有无效字符:window.showModalDialog(''ElapsedClockNonProd.aspx?code = 464'',null,``unadorned:yes; resizable:0; dialogWidth:300px; dialogHeight:300px ; status:no; scroll:no; status = no;''); .只能注册格式正确的脚本标签.
指导我如何解决此错误.每当我刷新该页面时,都会从pageload事件打开弹出窗口,但在按钮click事件上会引发此错误.
The same code i am applying on a Button on the same page then i am getting error.The error message is :- Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: The script tag registered for type ''ASP.associates_production_aspx'' and key ''OpenModalDialog'' has invalid characters outside of the script tags: window.showModalDialog(''ElapsedClockNonProd.aspx?code=464'', null, ''unadorned:yes ;resizable:0 ;dialogWidth:300px ;dialogHeight:300px ;status:no ;scroll:no ;status=no;''); . Only properly formatted script tags can be registered.
Guide me that how i fix this error.when ever i m refreshing that page, the pop up is opening from the pageload event but on the button click event it is throwing this error.
推荐答案
^ ]是您剥离特定于项目的信息并研究错误消息的方法.那里的一些答案应该会有所帮助.
This[^] is how you strip out the info specific to your project and research an error message. A few answers there that should help.
这篇关于修复-只能注册格式正确的脚本标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!