Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / February 2006

Tip: Looking for answers? Try searching our database.

how to assign session object to user control

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
c676228 - 14 Feb 2006 22:20 GMT
Hi all,
I have the following code, without option Strict  on, it seems work OK, but
when option strict is on. I have a problem for the assignment.

Dim ctrlarr(5) As PeopleInfo 'poepleinfo is user control in project
           Dim i As Integer
           If Not Session("ctrlarr") Is Nothing Then
               ctrlarr = Session("ctrlarr")
           End If
It says option strict on disallows implicit conversion from 'system.object'
to '1-dimensional array of subway.peopleinfo'
I guess I would have the same problem when I assign
Session("ctrlarr")=ctrlarry in the first page if I turn on  option Strict.
What should I do in this case?
Signature

Betty

GS - 14 Feb 2006 22:29 GMT
You have to cast to specific type before assiging it back.
In c# it will be ctrlarr = (subway.peopleinfo)Session("ctrlarr")
Not sure what VB cast looks like

> Hi all,
> I have the following code, without option Strict  on, it seems work OK,
[quoted text clipped - 12 lines]
> Session("ctrlarr")=ctrlarry in the first page if I turn on  option Strict.
> What should I do in this case?
c676228 - 15 Feb 2006 00:18 GMT
Hi GS,
I did
ctrlarr = CType(Session("ctrlarr"), PeopleInfo())
It didn't complain anything.
I haven't run the code, guess it's OK.
Thank you.

Signature

Betty

> You have to cast to specific type before assiging it back.
> In c# it will be ctrlarr = (subway.peopleinfo)Session("ctrlarr")
[quoted text clipped - 16 lines]
> > Session("ctrlarr")=ctrlarry in the first page if I turn on  option Strict.
> > What should I do in this case?
Steven Cheng[MSFT] - 15 Feb 2006 07:18 GMT
Hi Betty,

I suggest always explicitly cast object to their actual type since that'll
also help improve performance and avoid problem.

If there're any other problem, please feel free to post here.

Regards,

Steven Cheng
Microsoft Online Support

Signature

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.