Solved

access web control from vb class

Posted on 2012-04-13
10
257 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
 
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now