access web control from vb class

Hello

i ahve a vb.net web application and i would like to access a control from my .aspx page form my cv class.
LVL 1
Chris JonesLead Application Web DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chris JonesLead Application Web DeveloperAuthor Commented:
i have tried this but no help

        Dim PlaceHolderContact As New PlaceHolder
        PlaceHolderContact = MainPage.Parent.FindControl("Display")
        PlaceHolderContact.Controls.Add(t)
0
BuggyCoderCommented:
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
Chris JonesLead Application Web DeveloperAuthor Commented:
i dont realy understand your exmaple
0
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

Chris JonesLead Application Web DeveloperAuthor Commented:
ok i have this in my code now but i get an
0
CodeCruiserCommented:
Can you explain again what you are trying to do? Access a control on master page from content page?
0
Chris JonesLead Application Web DeveloperAuthor Commented:
ok got it from your exmple.. now i need to know can i access multiple controls from a class ?
0
BuggyCoderCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Chris JonesLead Application Web DeveloperAuthor Commented:
oh perfect thanks
0
Chris JonesLead Application Web DeveloperAuthor Commented:
Awesome thanks for the quick response
0
Chris JonesLead Application Web DeveloperAuthor Commented:
how do i pass the array over in my web form ?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.