Last post Apr 21, 2008 10:05 AM by John_Idol
Apr 18, 2008 02:17 PM|John_Idol|LINK
I just migrated a project from 1.1 to 2.0 (VS2005 Professional Edition - SP1).
Migration went fine, without any errors, just some warnings about resources moved to the proper asp.net folder. The project (now a web site project) compiles, builds and runs but I got some problems with user controls.
Any help would be highly appreciated!
Apr 18, 2008 03:13 PM|John_Idol|LINK
I put some breakpoints in there and I noticed it works alright the first time the page loads.
On the first Post back it throws the error. ViewState of the control is set to ture, but anyway it shouldn't throw
Object reference not set to an instance of an object
Ring any bells?
Apr 18, 2008 03:13 PM|allanhorwitz|LINK
Did you try using the old tag instead of the new one?
Apr 18, 2008 03:33 PM|John_Idol|LINK
What d'you mean?
Apr 18, 2008 03:42 PM|allanhorwitz|LINK
Is that typo in your code? NAMEOFCOTNROL? I imagine that could be NAMEOFCONTROL.
What d'you mean?
I am using: <WAS:NAMEOFCOTNROL
I mean the Register tags, did you try the old one.
Apr 18, 2008 03:48 PM|John_Idol|LINK
Thanks for answering,
Yep that's a typo, but just here when I deleted the control name.
I am using the old one (as I pasted above), as far as I know Reference is used to dinamically load the control, but I am statically placing it in the aspx file.
Apr 19, 2008 06:48 AM|John_Idol|LINK
I noticed that in VS2005 if you create a user control you Get "UserControls_" appended to the name you choose. So maybe there's something going on about names: the declaration of the user control as a member of my webform disappeared from my vb file, and
it's somewhere hiddend in those asp.usercontrols_MyControlxyd345.vb files, and when I hover of my instance member it tells me is declared as ASP.usercontrols_myControl_ascx.
My next shot will be refactor the MyControl class to UserControls_MyControl and see wtf happens.
The successive will be creating a new control from scratch and see if it goes.
I have a number of user controls in the application, the others are working fine, this one is giving me an hard time but I don't see any diference between them ... HELP! :-)
Apr 19, 2008 07:18 AM|John_Idol|LINK
Another thing I am noticing: If I hit F12 (go to definition) for the user control in my code behind it jumps always to the same point of the script section in the aspx. I don't know if just the navigation is broken or there's something more to it related
to my issue with the user control.
At this point I would treasure any suggestion!
Apr 21, 2008 08:01 AM|John_Idol|LINK
I repeated the migration process N times and I am getting consistent results: everything seems to be working fine except the user control in object.
I found out something very strange: First time the page is laoded I can programmatically access the user control but If I post it back it crashes, as I told above, BUT
if I browse somewhere else in the application then I go back to that page (so I am not doing a post back, but loading the page again from scratch) IT CRASHES. It doesn't make sense at all.
Looks like it works only the first ABSOLUTE time I load the page, postback crashes, if I browse somewhere else and then I go back to that form it crashes (always with the same Null reference error).
Any help much appreciated!
Apr 21, 2008 08:51 AM|John_Idol|LINK
I tried to put something like the pageload handler:
But I am getting this error: Unable to cast object of type 'MyControl' to type 'ASP.usercontrols_mycontrol_ascx'.
This must be a clue for someone who knows how to read it!
Apr 21, 2008 10:05 AM|John_Idol|LINK
I managed to get it working the way I want with this in the PageLoad handler:
Let me say it SUCKS BIGTIME because:
1) I shouldn't by any mean declare the control dynamically every time I load the page (as I am statically placing it on the markup)
2) My class is called MyControl but the ucMyControl member (which declaration disappeared after the conversion together with all the server controls - as I migrated to a website project) of the webform
is of type ASP.usercontrols_mycontrol_ascx
If anyone has some kind of explanation for this mess I'll be eternally grateful.