|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Casting ErrorI want to pass an information from one page to another page. I have a class MsgClass in a page and in the another page I created an object of this class MsgClass mc; for handeling I am using the following code void Page_Load() { if (!IsPostBack) { mc = (MsgClass)Context.Handler; } } it is giving the error Error is : System.InvalidCastException: Specified cast is not valid. then how to cast it. any Ideas??? I think it's because Context.Handler isn't a MsgClass object, so the
cast fails. Why not use either the Session object or the Cache object to pass data from one page to the next? e.g. : void Page_Load() { if (!IsPostBack) { mc = (MsgClass)Context.Session["myMsg"]; } } of course, in a previous page's Page_Load you'd have to have something like: Context.Session.Add("myMsg", MyMsgClassObj);
Other interesting topics
HELP: Table height in the new XHTML???
How to Remote a custom membership or profile provider ??? Populating FormView (asp.net 2.0 using vb.net) HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Word\UserData' do Unable to create the Web (W2003Std + Framework 2.0) remotely Adding domain user to local groups Where to set timeout Quotes, tags, and "greater than" signs GridView with dropdown: asp.net 2.0 Error accessing network resources in ASP.Net |
|||||||||||||||||||||||