473,770 Members | 4,355 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I find the components added to web form? (Urgent)

Hi there,

How can I find the components added to web form from my custom web
control?

Suppose I added a Timer component (with name "timer1") onto the web
form, from my user web
control, how can I locate the timer component by name "timer1"? The
Page.Controls collection only contains web controls but no components.

TIA, this is a urgent issue need to be resolved in my project.
-Martin
Nov 18 '05 #1
4 1588
Martin Hill wrote:
Hi there,

How can I find the components added to web form from my custom web
control?

Suppose I added a Timer component (with name "timer1") onto the web
form, from my user web
control, how can I locate the timer component by name "timer1"? The
Page.Controls collection only contains web controls but no components.

TIA, this is a urgent issue need to be resolved in my project.
-Martin


You can not add a Timer object to a form.
The Timer object has nothing to do with UI (user interface), it's a
object for the backend only, it's being used to trigger events on a
interval.

What did you expect? A clock on your page?

--

//Rutger

DoDotNet@KICKTH IS_Gmail.com
www.RutgerSmit.com
Nov 18 '05 #2
Martin,

See this sample I did make a while ago.

It is not real for production, I think it is to slow however in the Form1
page is the timer you need I thought,

I hope it helps you?

Cor

\\\Form 1 Needs a imagebox on the page
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
Me.Image1.Heigh t = New Unit(32)
Me.Image1.Width = New Unit(200)
Image1.Visible = True
Dim scriptString As String = "<script language=JavaSc ript>" & _
"setclock() ; function setclock(){docu ment.images.Ima ge1.src = " & _

"'http://localhost/WebClock/WebForm2.aspx'; setTimeout('set clock()',1000)} </s
cript>"
Page.RegisterSt artupScript("se tclock", scriptString)
End Sub
///
\\\Form2 needs nothing
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
Response.Cache. SetExpires(Date Time.Now.AddTic ks(500))
Dim myForeBrush As Brush = Brushes.Black
Dim myFont As New Font("Times New Roman", 8, FontStyle.Regul ar)
Dim textHeight As Single
Dim bm As New Bitmap(120, 20)
Dim g As Graphics = Graphics.FromIm age(bm)
g.Clear(Color.W hite)
Dim textSize As SizeF = g.MeasureString ("now.tostring" , myFont)
g.DrawString(No w.ToString, myFont, myForeBrush, _
New RectangleF(0, 0, 120, 20))
Dim ms As New IO.MemoryStream
Dim arrImage() As Byte
bm.Save(ms, Imaging.ImageFo rmat.Bmp)
arrImage = ms.GetBuffer
Response.Binary Write(arrImage)
g.dispose
End Sub
///

"Martin Hill"

How can I find the components added to web form from my custom web
control?

Suppose I added a Timer component (with name "timer1") onto the web
form, from my user web
control, how can I locate the timer component by name "timer1"? The
Page.Controls collection only contains web controls but no components.

TIA, this is a urgent issue need to be resolved in my project.
-Martin

Nov 18 '05 #3
Hi Martin,

From your description, you put a .net Timer component on the ASP.NET web
page and want to access this timer from a certain control on that page,
yes? As for this problem, here are some of my suggestions:

1. The timer is not a UI control so it is not added into control collection
and just be a member of the page class. So from a sub control on the page,
there isn't any buildin means to find the component. The only way is if we
know the web page's page class and explicitly access the timer through the
page's member. For example, we define a common base page class which has a
timer member field , then, we can access all those pages derived from the
base page as the base page class instance.

2. SINCE ASP.NET web page is request/response based, so the page's
lifecycle is only between the request comming to the server and the
respsonse be returned to client. Also, any components on the page also only
exist during the page's lifecycle. So I think use a timer at page level
won't work as what we expect because everytime a page is request, a new
timer is constructed and when the page is rendered out and unloaded , the
timer is also disposed. If you do want to do some repeatedly tasks
everytime a page is loaded on the serverside, or constantly post back a
page after a period of time, you can consider Cor 's suggestion about using
the client javascript "setTimeout " to constanly post back the page.
Also, here is a tech article discussing on building such a custom timer
server controL:

#Build a Custom AutoPostBack ASP.NET Page Timer ServerControl
http://www.eggheadcafe.com/articles/20021006.asp
In addition, in asp.net it's ok for us to build a Application scope
background timer which execute over the application's lifecycle and do some
background schedule tasks,here is also a blog thread discussing on this:

#Scheduled Execution in ASP.NET
http://weblogs.asp.net/ashben/archiv.../11/31579.aspx

Also, I've also tried build a appliation level background and store it in
ApplicationStat e collection, that also works, for example:

protected void Application_Sta rt(Object sender, EventArgs e)
{
System.Threadin g.Timer timer1 = new System.Threadin g.Timer(new
System.Threadin g.TimerCallback (this.CheckStat us),null,0,3000 );
Application["timer"] = timer1;
}

Hope helps..
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Nov 18 '05 #4
Hi Martin,

Have you had a chance to check out the suggestios in the former messages or
have you got any further ideas on this issue? If there are anything else we
can help, please feel free to post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #5

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

Similar topics

1
1503
by: paja | last post by:
Hello All I have been trying looking for Slider control required for one of the application. I have looked in default Form controls, then tried to add controls from COM components, but could not find one Can anybody please tell me where can I find such control or is there any external place/site where I can get such cotrolls. I have noticed that when adding any extra controlls it does have a file Browse option which indicates that...
7
1817
by: Peter van der Veen | last post by:
Hi I've a component (from the vb.net resource kit; the flexgroup component) But how can i add that to my form?? I don't see it in the components tab. In the example the component is on the form already, but there i also don't know hoe to add a new one beside kopie and paste.
6
1166
by: Roman | last post by:
I have a collection of custom components and using them only in code. I don't need to see them in designer. Is there a way to hide them? Thanks, Roman
2
1597
by: SteveT | last post by:
Is there a way to locate the most recent node added to any location within a TreeView? -- ----------- Thanks, Steve
4
2459
by: michael sorens | last post by:
In a Windows Form application, when a user resizes the window, I typically want different components in the form to take different actions. For example, a text box in the middle should grow with the window; a button panel at the bottom should remain the same height but re-center horizontally; etc. What I have settled on as a technique for managing this is to start witha table container (dock=fill), then by combining rowspans,...
7
1403
by: RBrowning1958 | last post by:
here's an easy one for you guys - .NET form designer generates this: private System.ComponentModel.IContainer components = null; but I don't see it used anywhere in the generated code - what's all that about? Also, it generates code to add the individual controls to Controls as in: this.Controls.Add(this.comboBox1); this.Controls.Add(this.menuStrip1);
5
4551
by: YaoBao | last post by:
Is any ColdFusion script I can put on my webpage that will create a search bar so people can type keywords to match it on the current page in my website? It will be exactly like the finder search bar that comes with your browser window, IE; click edit, then find on this page, which brings up the search box. I know that JavaScript can do this. I tried to insert JavaScript to my .cfm page. It doesn't work. Any help will be appreciated. Here...
7
6670
by: RichB | last post by:
I am trying to get to grips with the asp.net ajaxcontrol toolkit, and am trying to add a tabbed control to the page. I have no problems within the aspx file, and can dynamically manipulate a tabcontainer which has 1 panel already, however I want to try create the TabPanels dynamically. I followed the advice here: http://www.asp.net/learn/ajax-videos/video-156.aspx (3rd comment - Joe Stagner)
1
3770
by: squrel | last post by:
Hello all.. i need a very urgent help here... i have done a project in VB6 and SQLServer 2000 but few days back my pc had to get formatted and i took the back up of my project. i have installed VB again and my project also bt now when i want to run the project i m getting this error : Compile error : can't find project or library i have checked the components and refrences also and everything is thr bt still not opening... plz tel me wht...
0
9602
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9439
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10237
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5326
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5467
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3987
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3589
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2832
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.