TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
yinghui.zeng
NA
1
0
casting at runtime
Nov 4 2003 3:22 PM
I am trying to cast a user control at run time. Here are some code // load usercontrol, string userControlFileName="test.ascx"; Control rptCtl= LoadControl(userControlFileName); //get the type of the user control System.Type userControlType = rptCtl.GetType() // casting ((userControlType) rptCtl).setInfo(); The last line gave me compile error as follows "the type or namespace userControlType could not be found"; userControlFileName is determined at runtime, so the type of the user control has to be determined at runtime. I defined a method setInfo() in the user Control to define some class variables, in order to invoke this method, I have to cast the user control to its specific type. I have searched internet crazy and all I can find is an example that does the same thing as I did. Could anybody please help me out? Susan
Reply
Answers (
1
)
Overloads
Random seed numbers