0

Hi ,

I am new to asp.net .. I am trying to solve the invalid cast exception but facing some issues with that:

static private void RegisterJavaScriptFooter(string scriptName, StringBuilder scriptBlock)
    {

    ((PgDisplayBase)System.Web.HttpContext.Current.Handler).RegisterClientScriptFooterBlock(scriptName, scriptBlock.Insert(0, SetupJavaScriptHeader()).Append(SetupJavaScriptFooter()).ToString());
        }

I am getting the exception on this line :

Unable to cast object of type 'System.Web.DefaultHttpHandler' to type 'Intel.SWFactory.Platform.Common.PgDisplayBase'.

I tried resolving this as:

static private void RegisterJavaScriptFooter(string scriptName, StringBuilder scriptBlock)
    {

        try
        {
            ((PgDisplayBase)System.Web.HttpContext.Current.Handler).RegisterClientScriptFooterBlock(scriptName, scriptBlock.Insert(0, SetupJavaScriptHeader()).Append(SetupJavaScriptFooter()).ToString());
        }
        catch (InvalidCastException e)
        {
            throw(e);
    }
        }

but nothing works out ..

Edited by pyTony: fixed formating

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by Momerath
0

What it is telling you is that there is no method to cast the DefaultHttpHandler into PgDisplayBase. You'll either have to develop your own or find if the PgDisplayBase class has a method you can call to convert it.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.