Solved

access web control from vb class

Posted on 2012-04-13
10
261 Views
Last Modified: 2012-04-17
Hello

i ahve a vb.net web application and i would like to access a control from my .aspx page form my cv class.
0
Comment
Question by:Chris Jones
  • 7
  • 2
10 Comments
 
LVL 1

Author Comment

by:Chris Jones
ID: 37845021
i have tried this but no help

        Dim PlaceHolderContact As New PlaceHolder
        PlaceHolderContact = MainPage.Parent.FindControl("Display")
        PlaceHolderContact.Controls.Add(t)
0
 
LVL 20

Assisted Solution

by:BuggyCoder
BuggyCoder earned 500 total points
ID: 37845595
you have to pass an instance of your control to you vb class like this:-

<asp:Button id="button1" runat="server" />

code behind:-
Public Partial Class _Default
	Inherits System.Web.UI.Page
	Protected Sub Page_Load(sender As Object, e As EventArgs)
		Dim type As New MyType(button1)

	End Sub
End Class

Open in new window


vb class:-

Public Class MyType
	Private _control As Control

	Public Sub New(control As Control)
		_control = control
	End Sub
End Class

Open in new window

0
 
LVL 1

Author Comment

by:Chris Jones
ID: 37851249
i dont realy understand your exmaple
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 1

Author Comment

by:Chris Jones
ID: 37851296
ok i have this in my code now but i get an
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 37853596
Can you explain again what you are trying to do? Access a control on master page from content page?
0
 
LVL 1

Author Comment

by:Chris Jones
ID: 37857725
ok got it from your exmple.. now i need to know can i access multiple controls from a class ?
0
 
LVL 20

Accepted Solution

by:
BuggyCoder earned 500 total points
ID: 37857937
Simple use Array of Control in Constructor:-
Public Class MyType
	Private _control As Control()

	Public Sub New(control As Control())
		_control = control
	End Sub
End Class

Open in new window

0
 
LVL 1

Author Comment

by:Chris Jones
ID: 37858164
oh perfect thanks
0
 
LVL 1

Author Closing Comment

by:Chris Jones
ID: 37858166
Awesome thanks for the quick response
0
 
LVL 1

Author Comment

by:Chris Jones
ID: 37858177
how do i pass the array over in my web form ?
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question