views:

39

answers:

2

I have a simpleAsp.net page which I make it Ajaxable. everything works fine but I face with a problem whenever a specific method calls.

Actually the Browser tell me that

  Sys.WebForms.PageRequestManagerServerErrorException: Unable to cast object of type 'System.Web.UI.LiteralControl' to type 'System.Web.UI.WebControls.WebControl'.

I do not know how to resolve it. Any help appriciates.


Update : here is the code : I'll remove this section after getting answer

I removd the code because there were no answer

+1  A: 
  1. Find the exact line that throws the error. You can try checking the 'break when exceptions are thrown' option or just stepping throw the code using you debugger.

  2. The find the id of the control that is causing that exception to be thrown and try adding runat="server" to it's declaration. That would make a server-side control. alternatively, you can fix the cast.

You are basically try to cast a literal control that was created due to literal text on the page ( ie. not a server control in the strictest since, though it can be accessed on the server ) to a full-blown server control. You should be able to pinpoint the offending cast quickly with a debugger.

See this short article on Dynamic Controls for a little background.

kervin
A: 

As I put the codes. and I work with this issue I found that when I use TemplateColumn for Edit/Update/Cancel/Delete and Select I face with this problem, so I change TemplateColumn to ButtonColumn and issue resolved

Thank you all

Nasser Hadjloo