Bodybag Posted January 21, 2004 Posted January 21, 2004 This may sound rather stupid but i must be missing something.When i create a web control and drag onto a web form.How do i access it from my form code. It does not create instance of the control.I have used the findcontrol method .But it seems like a long way around .Is there no other way. What i want to do is use it like any normal web control ex dropdownlist. Quote Programmers are trying to create bigger and beter idiot proof programs.The universe is trying to create bigger and beter idiots and so far the universe is winning.
Administrators PlausiblyDamp Posted January 21, 2004 Administrators Posted January 21, 2004 You can declare a variable in the code-begind of the same name and type e.g. If you drag a webcontrol of type mycontrol onto a webpage and it has the name mycontrol1 in the code behind declare it as protected mycontrol1 as mycontrol Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Bodybag Posted January 21, 2004 Author Posted January 21, 2004 The following is what i did.Basicly the same so there is no other way. Protected myWEBcontrol1 As WebUserControl1 Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor. myWEBcontrol1 = CType(Me.FindControl("MYWEBCONTROL1"), WebUserControl1) InitializeComponent() End Sub #End Region Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here Me.myWEBcontrol1.Button1.Text = "DD" End Sub Quote Programmers are trying to create bigger and beter idiot proof programs.The universe is trying to create bigger and beter idiots and so far the universe is winning.
Administrators PlausiblyDamp Posted January 21, 2004 Administrators Posted January 21, 2004 If you declare it like you have you shouldn't need the find control bit. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Bodybag Posted January 21, 2004 Author Posted January 21, 2004 I will try that. THanks. Quote Programmers are trying to create bigger and beter idiot proof programs.The universe is trying to create bigger and beter idiots and so far the universe is winning.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.