Visual Basic .NET » ASP.NET General Discussion
Invalid cast in the error.Message -- Chris --


I've got what I believe to be the most straightforward implementation in which I'm registering a type for Ajax (including the optional Page parameter), decorating my public method with AjaxPro.WebMethod(), and then calling the method from script. Each time I get an invalid cast exception returned in the error object. My Ajax method is never called. The class I'm registering is a user control that inherits from a base class and the page inherits from a base class as well. Is this an issue anyone else has dealt with? I've successfully used AJAX.NET
(an amazing tool) in other applications, but I can't seem to get it to work in this one.

-- Michael Schwarz --


Hi,

can you post your source code (or send it to my email address)? And,
did you had a look at the example source code at
http://www.codeplex.com 
/?

Regards,
Michael
On 7/6/06, Chris wrote:

I've got what I believe to be the most straightforward implementation
in which I'm registering a type for Ajax (including the optional Page
parameter), decorating my public method with AjaxPro.WebMethod(), and
then calling the method from script. Each time I get an invalid cast
exception returned in the error object. My Ajax method is never
called. The class I'm registering is a user control that inherits from
a base class and the page inherits from a base class as well. Is this
an issue anyone else has dealt with? I've successfully used AJAX.NET
(an amazing tool) in other applications, but I can't seem to get it to
work in this one.
>

--  

Best regards | Schöne Grüße Michael

Microsoft MVP - Most Valuable Professional Microsoft MCAD - Certified Application Developer

http://weblogs.asp.net/mschwarz 
/
http://www.schwarz-interactive.de 
/
mailto:info
-- Chris --


I've looked extensively at the examples and also successfully used your tool. This error is a mystery. Here is the appropriate source.

In Page_Load of MemberChain.Controls.MemberControls.MeetingEditor.ascx.cs (inherits from MemberChainUserControl):
AjaxPro.Utility.RegisterTypeForAjax(typeof(Recurrence), this.Page);

In MemberChain.Controls.MemberControls.Recurrence.ascx.cs (inherits from MemberChainUserControl):

public string GetTextualRecurrence()
{
return "Work now";
}

In MemberChain.Controls.MemberControls.MeetingEditor.ascx function ShowRecurrenceModal()
{
var res =
MemberChain.Controls.MemberControls.Recurrence.GetTextualRecurrence();
alert(res.value);
if (res.error != null)
{
alert(res.error.Message);
}
return;
}

I've stepped through the script, and it's properly making the request it seems, but the breakpoint in the codebehind for the GetTextualRecurrence() method never gets hit. I assume the exception is coming from someplace earlier, but I don't know where to put a breakpoint to debug.

-- Chris --


I found that if I just create a simple class and do the same thing, it works, so the problem is only when trying to register the usercontrol as the type in the RegisterTypeForAjax method.

[Submit Comment]Home