Solved

access web control from vb class

Posted on 2012-04-13
10
265 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

749 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