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);
}
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.I am not getting that why on the button click it is not working but while page load the same script is working without any issues..
1 Answer