开发者

Handling Page.Response object in a custom class

I have a custom class, Customer. I want to show a JQuery message on exception. I am attempting following class but the problem is that Page.Response object is unavailable in a custom class.

How to开发者_如何学Go modify the exception line in below given code? I have a separate class named as: MyErrorHandler, that stores all the methods for error handling. Code of both the classes is given below:

public sealed class Customer
{

     public void FillList()
     {
        try
        {
                .....
        }
        catch (Exception ex)
        {
             MyErrorHandler.GetScript(Page.Response,ex.Message.ToString());
        }
}

public static class MyErrorHandler
{
    public static void GetScript(System.Web.HttpResponse r, string customErrorMessage)
    {
        r.Write("<script type='javascript'>$.msg({ content : '" + customErrorMessage + "' });</script>");
    }
}         


You can use HttpContext.Current.Response

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜