473,383 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Help with use of class file....

I need some help understanding how I can create a function in a class file
that is available to every page on my site and that can interact with a
placeholder control that is already on the page. Below is a code sameple that
doesn't work, could someone point me in the right direction?

---from Global_Class.vb

Public Class Global_Class

Public Sub add_control_test(byref placeholder as
system.ui.webcontrols.placeholder)

dim new_text_box as System.web.ui.webcontrols.textbox
new_text_box.text="test"

placeholder.controls.add(new_text_box)

End Class
---from default.aspx
<body blah blah>

<asp:placeholder id="PlaceHolder1" runat="server"></asp:placeholder>

</html> yada yadda
---from default.aspx.vb

Public Class _default
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

Dim global_class As New <website>.Global_Class

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

global_class.add_control_test(PlaceHolder1)
End Sub

End Class
Any help would be greatly appreciated!

TIA,
Blax...
Nov 18 '05 #1
3 1303
Blaxer, it looks fine. What doesn't work about it? An error or the textbox
just doesn't show up?

Two notes, you don't have to pass the placeholder byref...byval is fine, but
that won't change anything

and declare you sub as shared ala public shared sub add_.....
then you can get rid of the Dim global_class As New <website>.Global_Class
and just call <website>.Global_Class.add_... without an instance of the
class..but again I that won't change anything.

Karl

"Blaxer" <Bl****@discussions.microsoft.com> wrote in message
news:98**********************************@microsof t.com...
I need some help understanding how I can create a function in a class file
that is available to every page on my site and that can interact with a
placeholder control that is already on the page. Below is a code sameple that doesn't work, could someone point me in the right direction?

---from Global_Class.vb

Public Class Global_Class

Public Sub add_control_test(byref placeholder as
system.ui.webcontrols.placeholder)

dim new_text_box as System.web.ui.webcontrols.textbox
new_text_box.text="test"

placeholder.controls.add(new_text_box)

End Class
---from default.aspx
<body blah blah>

<asp:placeholder id="PlaceHolder1" runat="server"></asp:placeholder>

</html> yada yadda
---from default.aspx.vb

Public Class _default
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

Dim global_class As New <website>.Global_Class

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

global_class.add_control_test(PlaceHolder1)
End Sub

End Class
Any help would be greatly appreciated!

TIA,
Blax...

Nov 18 '05 #2
Hmmm, it doesn't seem to work at all, it complains about needing a child
object for the placeholder inside the class file... ??

Blax...

"Karl" wrote:
Blaxer, it looks fine. What doesn't work about it? An error or the textbox
just doesn't show up?

Two notes, you don't have to pass the placeholder byref...byval is fine, but
that won't change anything

and declare you sub as shared ala public shared sub add_.....
then you can get rid of the Dim global_class As New <website>.Global_Class
and just call <website>.Global_Class.add_... without an instance of the
class..but again I that won't change anything.

Karl

"Blaxer" <Bl****@discussions.microsoft.com> wrote in message
news:98**********************************@microsof t.com...
I need some help understanding how I can create a function in a class file
that is available to every page on my site and that can interact with a
placeholder control that is already on the page. Below is a code sameple

that
doesn't work, could someone point me in the right direction?

---from Global_Class.vb

Public Class Global_Class

Public Sub add_control_test(byref placeholder as
system.ui.webcontrols.placeholder)

dim new_text_box as System.web.ui.webcontrols.textbox
new_text_box.text="test"

placeholder.controls.add(new_text_box)

End Class
---from default.aspx
<body blah blah>

<asp:placeholder id="PlaceHolder1" runat="server"></asp:placeholder>

</html> yada yadda
---from default.aspx.vb

Public Class _default
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

Dim global_class As New <website>.Global_Class

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

global_class.add_control_test(PlaceHolder1)
End Sub

End Class
Any help would be greatly appreciated!

TIA,
Blax...


Nov 18 '05 #3
Oppss..one thing i just noticed is that you never actually create a new
textbox:
dim new_text_box as System.web.ui.webcontrols.textbox
should be
dim new_text_box as NEW System.web.ui.webcontrols.textbox

your naming convention makes things like that hard to spot..

karl

"Blaxer" <Bl****@discussions.microsoft.com> wrote in message
news:76**********************************@microsof t.com...
Hmmm, it doesn't seem to work at all, it complains about needing a child
object for the placeholder inside the class file... ??

Blax...

"Karl" wrote:
Blaxer, it looks fine. What doesn't work about it? An error or the textbox just doesn't show up?

Two notes, you don't have to pass the placeholder byref...byval is fine, but that won't change anything

and declare you sub as shared ala public shared sub add_.....
then you can get rid of the Dim global_class As New <website>.Global_Class and just call <website>.Global_Class.add_... without an instance of the
class..but again I that won't change anything.

Karl

"Blaxer" <Bl****@discussions.microsoft.com> wrote in message
news:98**********************************@microsof t.com...
I need some help understanding how I can create a function in a class file that is available to every page on my site and that can interact with a placeholder control that is already on the page. Below is a code
sameple that
doesn't work, could someone point me in the right direction?

---from Global_Class.vb

Public Class Global_Class

Public Sub add_control_test(byref placeholder as
system.ui.webcontrols.placeholder)

dim new_text_box as System.web.ui.webcontrols.textbox
new_text_box.text="test"

placeholder.controls.add(new_text_box)

End Class
---from default.aspx
<body blah blah>

<asp:placeholder id="PlaceHolder1" runat="server"></asp:placeholder>

</html> yada yadda
---from default.aspx.vb

Public Class _default
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

Dim global_class As New <website>.Global_Class

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

global_class.add_control_test(PlaceHolder1)
End Sub

End Class
Any help would be greatly appreciated!

TIA,
Blax...


Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: fabien | last post by:
Hi, I am writing a POV-RAY editor with Python using either QT or GTK as GUI 'wrapper'. ( I am still trying both ) * * * * PYGTK * * * * I have downloaded PygtkScintilla-1.99.5. There is a...
0
by: J. | last post by:
Hello all, I need some assistance. I've been out of the C++ game way too long and I need some help getting back up to speed. I'm taking a class where STL is mostly covered...I know alot of...
1
by: Esteban Felipe | last post by:
Hi, thanks for reading. I hope to find some help here before I commit suicide because this is driving me crazy. Please excuse me if this looks like a long post, but I hope that a complete...
6
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
5
by: SStory | last post by:
Hi all, I really needed to get the icons associated with each file that I want to show in a listview. I used the follow modified code sniplets found on the internet. I have left in...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
1
by: dasilva109 | last post by:
Hi guys I am new to C++ and need urgent help with this part of my code for a uni coursework I have to submit by Thursday //ClientData.h #ifndef CLIENTDATA_H #define CLIENTDATA_H #include...
2
by: dasilva109 | last post by:
Hi guys I am new to C++ and need urgent help with this part of my code for a uni coursework I have to submit by Thursday //ClientData.h #ifndef CLIENTDATA_H #define CLIENTDATA_H #include...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
2
budigila
by: budigila | last post by:
Hiya peeps, Okies, I have been trying to work this out for a while now to no avail... I am a beginner to this whole coding thing but have made great strides in my project. Basically what I am...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.