473,667 Members | 2,692 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to pass an <asp:Label to a thread

I need to update the .Text of a label until the user logs out.

but get this error:

Error: Method name expected

I have listed the code below and the offending line of code is delimited by

//The next line breaks: Error: Method name expected
Thank you,

John Bickmore

+++++++++++++++ +++++++++++++++ ++++++++++
In code behind of footer.aspx

A. Parameters:
1. ctlLabel is an <asp:Label
2. SessionStartTim e is the System.DateTime .Now of when the viewer
logged in

B. In Footer.aspx.cs, the thread is created with:

fFooter myFooter = new fFooter();
myFooter.Update (ctlLabel,Sessi onStartTime);

+++++++++++++++ +++++++++++++++ ++++++++++
using System;
using System.Threadin g;

namespace fFooter
{
/// <summary>
/// Summary Called from Footer.aspx.cs to update the footer with
/// Summary the time in minutes the viewer has been logged in.
/// </summary>
public class fFooter
{
public Thread myThread;

//Parameter(s)
System.DateTime xSessionStartTi me;

public void Update(System.W eb.UI.WebContro ls.Label yLabel, System.DateTime
ySessionStartTi me)
{
xSessionStartTi me = ySessionStartTi me;
//The next line breaks: Error: Method name expected

myThread=new Thread(new ThreadStart(Upd ateLabel(yLabel )));

//The line above breaks: Error: Method name expected

myThread.Start( );
}

private void UpdateLabel(Sys tem.Web.UI.WebC ontrols.Label yLabel)
{
while ( true )
{
yLabel.Text = tTime(xSessionS tartTime);
Thread.Sleep(10 00);
}
}

private string tTime(System.Da teTime xSessionStartTi me)
{
string xx = "Active for: ";
System.DateTime dtBdate = xSessionStartTi me;
System.DateTime dtToday = System.DateTime .Now;
System.TimeSpan tsTotal = dtBdate - dtToday;
decimal xDECIMAL = Convert.ToDecim al(tsTotal.Tota lMinutes * -1);
int xINT = Convert.ToInt32 (decimal.Round( xDECIMAL,0));

if (xINT < 1 )
{
return "Just logged in";
}
else
{
if (xINT == 1)
{
return xx + "1 minute";
}
else
{
return xx + xINT + " minutes";
}
}
}//end of method: tTime
}//end of class: Footer
}//end of Namespace: clsFooter

Nov 19 '05 #1
2 1523
ThreadStart takes a delegate to a method with no params and no return (and
in 2.0 there's another version that accepts an object parameter). But I have
a feeling that even if you got the delegate right, it's still not going to
do what you want. If you spin up another thread, the first thread will continue
processing and render the result back to the browser. Your secondary thread
will kick in at some point and try to update a control on the page that probabaly
has already been rendered out to the client. In short, I think you're going
to have problems. What exactly are you trying to do?

-Brock
DevelopMentor
http://staff.develop.com/ballen
I need to update the .Text of a label until the user logs out.

but get this error:

Error: Method name expected

I have listed the code below and the offending line of code is
delimited by

//The next line breaks: Error: Method name expected

Thank you,

John Bickmore

+++++++++++++++ +++++++++++++++ ++++++++++
In code behind of footer.aspx
A. Parameters:
1. ctlLabel is an <asp:Label
2. SessionStartTim e is the System.DateTime .Now of when the viewer
logged in
B. In Footer.aspx.cs, the thread is created with:

fFooter myFooter = new fFooter();
myFooter.Update (ctlLabel,Sessi onStartTime);
+++++++++++++++ +++++++++++++++ ++++++++++
using System;
using System.Threadin g;
namespace fFooter
{
/// <summary>
/// Summary Called from Footer.aspx.cs to update the footer with
/// Summary the time in minutes the viewer has been logged in.
/// </summary>
public class fFooter
{
public Thread myThread;
//Parameter(s)
System.DateTime xSessionStartTi me;
public void Update(System.W eb.UI.WebContro ls.Label yLabel,
System.DateTime
ySessionStartTi me)
{
xSessionStartTi me = ySessionStartTi me;
//The next line breaks: Error: Method name expected

myThread=new Thread(new ThreadStart(Upd ateLabel(yLabel )));

//The line above breaks: Error: Method name expected

myThread.Start( );
}
private void UpdateLabel(Sys tem.Web.UI.WebC ontrols.Label yLabel)
{
while ( true )
{
yLabel.Text = tTime(xSessionS tartTime);
Thread.Sleep(10 00);
}
}
private string tTime(System.Da teTime xSessionStartTi me)
{
string xx = "Active for: ";
System.DateTime dtBdate = xSessionStartTi me;
System.DateTime dtToday = System.DateTime .Now;
System.TimeSpan tsTotal = dtBdate - dtToday;
decimal xDECIMAL = Convert.ToDecim al(tsTotal.Tota lMinutes * -1);
int xINT = Convert.ToInt32 (decimal.Round( xDECIMAL,0));
if (xINT < 1 )
{
return "Just logged in";
}
else
{
if (xINT == 1)
{
return xx + "1 minute";
}
else
{
return xx + xINT + " minutes";
}
}
}//end of method: tTime
}//end of class: Footer
}//end of Namespace: clsFooter

Nov 19 '05 #2
I need to do something to fire:

Application_Pre RequestHandlerE xecute

without the viewer having to do anything.

John
"Brock Allen" <ba****@NOSPAMd evelop.com> wrote in message
news:b8******** *************** ***@msnews.micr osoft.com...
ThreadStart takes a delegate to a method with no params and no return (and
in 2.0 there's another version that accepts an object parameter). But I have a feeling that even if you got the delegate right, it's still not going to
do what you want. If you spin up another thread, the first thread will continue processing and render the result back to the browser. Your secondary thread will kick in at some point and try to update a control on the page that probabaly has already been rendered out to the client. In short, I think you're going to have problems. What exactly are you trying to do?

-Brock
DevelopMentor
http://staff.develop.com/ballen
I need to update the .Text of a label until the user logs out.

but get this error:

Error: Method name expected

I have listed the code below and the offending line of code is
delimited by

//The next line breaks: Error: Method name expected

Thank you,

John Bickmore

+++++++++++++++ +++++++++++++++ ++++++++++
In code behind of footer.aspx
A. Parameters:
1. ctlLabel is an <asp:Label
2. SessionStartTim e is the System.DateTime .Now of when the viewer
logged in
B. In Footer.aspx.cs, the thread is created with:

fFooter myFooter = new fFooter();
myFooter.Update (ctlLabel,Sessi onStartTime);
+++++++++++++++ +++++++++++++++ ++++++++++
using System;
using System.Threadin g;
namespace fFooter
{
/// <summary>
/// Summary Called from Footer.aspx.cs to update the footer with
/// Summary the time in minutes the viewer has been logged in.
/// </summary>
public class fFooter
{
public Thread myThread;
//Parameter(s)
System.DateTime xSessionStartTi me;
public void Update(System.W eb.UI.WebContro ls.Label yLabel,
System.DateTime
ySessionStartTi me)
{
xSessionStartTi me = ySessionStartTi me;
//The next line breaks: Error: Method name expected

myThread=new Thread(new ThreadStart(Upd ateLabel(yLabel )));

//The line above breaks: Error: Method name expected

myThread.Start( );
}
private void UpdateLabel(Sys tem.Web.UI.WebC ontrols.Label yLabel)
{
while ( true )
{
yLabel.Text = tTime(xSessionS tartTime);
Thread.Sleep(10 00);
}
}
private string tTime(System.Da teTime xSessionStartTi me)
{
string xx = "Active for: ";
System.DateTime dtBdate = xSessionStartTi me;
System.DateTime dtToday = System.DateTime .Now;
System.TimeSpan tsTotal = dtBdate - dtToday;
decimal xDECIMAL = Convert.ToDecim al(tsTotal.Tota lMinutes * -1);
int xINT = Convert.ToInt32 (decimal.Round( xDECIMAL,0));
if (xINT < 1 )
{
return "Just logged in";
}
else
{
if (xINT == 1)
{
return xx + "1 minute";
}
else
{
return xx + xINT + " minutes";
}
}
}//end of method: tTime
}//end of class: Footer
}//end of Namespace: clsFooter


Nov 19 '05 #3

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

Similar topics

1
1578
by: John Smith | last post by:
I created a dataTable that returns a value from a stored procedure. How would I bind that results of a query to an <asp:label>? Thank you!
7
3576
by: Venus | last post by:
Hello, I am trying to generate a dynamic form at runtime and would like to do it using "<asp: ..." form elements as follows Build up the string that is placed somewhere in the HTML code the same way like regular input fields can. strForm = "<form name=""myForm"" runat=""server"">" & vbCrLf strForm += "<asp:button name=""myName"" .... runat=""server"" />" & vbCrLf
6
2926
by: Andreas Klemt | last post by:
Hello, when I use <asp:label font-size="16px" text="Hello World" runat="server" /> and run FireFox Browser the output of "Hello World" is not in Size 16px. The size will be ignored and I can not find it in the HTML Source Code. Why is it a problem with FireFox and what is the solution how to set sizes in Labels?
5
1415
by: Johnb41 | last post by:
I want an "order number" to be displayed more than once on my page. <script language="vb" runat="server"> ... dim ordernumber as string = "123456" page.databind() ... </script>
3
3439
by: nick | last post by:
Is possible for server side code to access the text of <asp:label> changed by client side javascript code?
4
2212
by: Satya | last post by:
Hi all, The following code is throwing a run time error "The server tag is not well formed. " <ItemTemplate> <asp:HyperLink Runat="server" ID="lnkFile" NavigateUrl="javascript:OpenImage('<%# DataBinder.Eval(Container.DataItem,"FileName") %>');"><%#
4
1356
by: mark.norgate | last post by:
Why oh why does my <asp:labelrevert to its initial value, having been changed programmatically, when I click a button in a user control I have added dynamically to the page? It's EnableViewState is set to true. Mark
8
4503
by: gelligokul | last post by:
Hello frens i want to retrieve <asp:label> value from the code behind in c# can any one help me...
3
2564
by: Homer J. Simpson | last post by:
I have the following stored procedure: ALTER PROCEDURE . AS BEGIN SET NOCOUNT ON; SELECT COUNT(*) FROM QUICKNOTES END ....and the following data source in my .aspx file:
0
8458
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
8888
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...
0
8790
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8650
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7391
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5677
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2779
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
2017
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.