Saturday, October 3, 2009

If u Get this Error :

{System.InvalidCastException: Unable to cast object of type 'System.Web.UI.HtmlControls.HtmlInputHidden' to type 'System.Web.UI.WebControls.HiddenField'}

the Cause is :

HiddenField hid = (HiddenField)cph_Main.FindControl("hidControl");

in asp.net there are bascially 2 types of controls
1. HtmlControls : in namespace :- System.Web.UI.HtmlControls
2. Webcontrols : in namespace: - System.Web.UI.WebControls

now if 'hidControl' is a html input field then it can't be convertes to
asp.net webcontrol's hidden feild.

Solution is very simple:

HtmlInputHidden hidContent = (HtmlInputHidden)cph1.FindControl("hidRedirect");

No comments:

Post a Comment