Display popup to user in asp.net application (popup from local application is displayed contrary to popup from server deployed application)

无人久伴 提交于 2019-12-12 01:55:30

问题


I am developping an asp.net application. When an user clicks on a button, he calls a webservice passing also the parameter he has before entered in a textfield. When the webservice returns no results, it displays a popup, everything works well in local, but when I deploy my application on my windows server, the pop up is not displayed. This is my code:

        if (!string.IsNullOrEmpty(textbox.text))
        {
            try
            {
               //webservice call
               string result = webservice.function(textbox.text);
            }
            catch (SoapException ex)
            {
                Utils.Log_File(ex.Message);
                Utils.Log_File(ex.StackTrace);
                string message = ex.Message;
                //this popup is not working on the deployed application
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "error from code behind", string.Format("alert('{0}')", message), true);
            }
        }

I debug my code from client side in chrome to see the error. When I debug the localhost everything works well, the popup from soapexception is displayed with this message '[E_E1] [Parameter NotFound]'

When I debug the server app, I am getting this error in chrome console :

<script type="text/javascript">
//<![CDATA[
alert('System.Web.Services.Protocols.SoapException: [E_E1] [Parameter NotFound]
    [uncaught syntaxerror unexpected token illegal]
....

回答1:


Try using ClientScript.RegisterStartupScript(this.GetType(), "Error", "alert('"+MailMessage+"');");



来源:https://stackoverflow.com/questions/27101932/display-popup-to-user-in-asp-net-application-popup-from-local-application-is-di

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!