Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Early binding

Status
Not open for further replies.

s2001

Programmer
Dec 7, 2001
132
US
Hello all;

In asp.net 1.1 i was able to do the following--

1. Create a user control - myusercontrol.ascx
2. In the default.aspx page add the following code:

dim myCtrl as myusercontrol
myCtrl=LoadControl("myusercontrol.ascx")

But in ASP.NET 2.0 i am unable to do the above. That is,
I am able to create the control as Public. But when i try to define a variable i don't see myusercontrol as choice.

Can some one guide me?

Thanks a bunch.

Thanks,
MB
 
Have you added a Register directive on the page for the usercontrol?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
thanks for the response ca8msm. I don't think we need to do that. I know for sure (also double checked in a 1.1 version) i did not have to register the control to use it while declaring variable.


Thanks,
MB
 
Yes, it has changed, and I don't know what is different or why. I would really like to know if someone has information. I found this way of doing what you want, just a little different.
Code:
Dim c1 As Control = LoadControl("myusercontrol.ascx")
        Page.FindControl("Form1").Controls.Add(c1)

Jim
 
thanks jbenson001. Now i need a suggestion. I have events declared in myUserControl. I adding handler in the default.aspx page to handle the events. Here's the code i had in 1.x version. Can anybody tell how to implement the same in 2.0

-----------------------------------------------------------

myUserControl.ascx
Public Class GeneralsubMenu
Inherits System.Web.UI.UserControl
Public Event GenericViewEvent()
Protected Sub genericView_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles genericView.Click
RaiseEvent GenericViewEvent()
End Sub
End Class

Default.aspx
Protected WithEvents cMenu As GeneralsubMenu
cMenu = LoadControl("GeneralsubMenu.ascx")
AddHandler cMenu.GenericViewEvent, AddressOf RunTask

sub RunTask()
'Do task
end sub

Thanks,
MB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top