Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Simple problem

Reply
Thread Tools

Simple problem

 
 
Steven
Guest
Posts: n/a
 
      03-29-2005
Hello,
First, let me state that I am trying to learn asp.net, so I am a beginner.
Now on to the issue. I have a webform with a single Textbox and a
FileSystemWatcher monitoring a directory for OnCreate events. I am trying
to change the text in response to an OnCreate event. I would like to change
the Forecolor to red, from black. Apparently, this is not as easy to do as
in vb.net. I have tried the direct approach in the OnCreate event;
"Textbox1.Forecolor = Color.Red". This produces no results. I have tried
applying a style to the Textbox, no results. Server.Tranfer to another page
produces a "Object not set to an instance" error. Server.Transfer to the
same page does nothing. What do I need to do to accomplish this simple
task?

Thanks,
Steven


 
Reply With Quote
 
 
 
 
Kevin Spencer
Guest
Posts: n/a
 
      03-29-2005
Hi Steven,

I hope you'll pardon me if I only point you in the right direction.

An ASP.Net app is a client-server app, with HTTP as the transport between
client and server. HTTP is stateless, so the only communication between
client and server is via Requests from the client browser.

You have a FileSystemWatcher on the server, which is monitoring for events.
On the client, you have a disconnected web page and a browser. Can a
disconnected browser receive events on the server? No. So, how DO you
respond to server-side events in the client? Well, now it doesn't seem so
simple, does it?

First of all, the FileSystemWatcher raises an event whenever you tell it to
(OnCreate). This event fires asynchronously on the server. IOW, it can fire
at any time. The only time you can update the client from the server is when
you receive a Request from the client. The Request can come at any time. So,
how do we synchronise the server-side event to the client?

The answer is, we don't. We can't. What we CAN do is to create some
persistent server-side objects that remain across Requests, handle the
OnCreate event from the FileSystemWatcher, and maintains state until a fresh
Request comes in from the client. At that point (Request) we can update the
client.

Next question: How does the client know when to do a PostBack for getting
the update? Again, it doesn't. It can't. It's disconnected. So, what can you
do? You can set up a timing mechanism on the client that refreshes the page
(makes a fresh Request) at intervals. This can be done with JavaScript or a
META Refresh tag on the client.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"Steven" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
> First, let me state that I am trying to learn asp.net, so I am a
> beginner.
> Now on to the issue. I have a webform with a single Textbox and a
> FileSystemWatcher monitoring a directory for OnCreate events. I am trying
> to change the text in response to an OnCreate event. I would like to
> change
> the Forecolor to red, from black. Apparently, this is not as easy to do
> as
> in vb.net. I have tried the direct approach in the OnCreate event;
> "Textbox1.Forecolor = Color.Red". This produces no results. I have tried
> applying a style to the Textbox, no results. Server.Tranfer to another
> page
> produces a "Object not set to an instance" error. Server.Transfer to the
> same page does nothing. What do I need to do to accomplish this simple
> task?
>
> Thanks,
> Steven
>
>



 
Reply With Quote
 
 
 
 
Marcus Monaghan
Guest
Posts: n/a
 
      03-29-2005
Stephen,

From what I can gather from the information you have provided you are
trying to change the background colour of the text box without reloading
the page. Web pages work on a pull technology, it needs to ask for new
information. I'd say you'll have to implement some kind of polling
mechanism where the page gets refreshed every so often.

I'm unfamiliar with the FileSystemWatcher and therefore don't know
whether you are monitoring a directory on the client or server machine?
If it's the client machine then you might be able to do something with
some [java-vb]script.

Regards,
Marcus

Steven wrote:
> Hello,
> First, let me state that I am trying to learn asp.net, so I am a beginner.
> Now on to the issue. I have a webform with a single Textbox and a
> FileSystemWatcher monitoring a directory for OnCreate events. I am trying
> to change the text in response to an OnCreate event. I would like to change
> the Forecolor to red, from black. Apparently, this is not as easy to do as
> in vb.net. I have tried the direct approach in the OnCreate event;
> "Textbox1.Forecolor = Color.Red". This produces no results. I have tried
> applying a style to the Textbox, no results. Server.Tranfer to another page
> produces a "Object not set to an instance" error. Server.Transfer to the
> same page does nothing. What do I need to do to accomplish this simple
> task?
>
> Thanks,
> Steven
>
>

 
Reply With Quote
 
Eliyahu Goldin
Guest
Posts: n/a
 
      03-29-2005
Steven,

Putting FileSystemWatcher on a web form doesn't make much sense. A web form
lives very short time, from the moment when an http request arrives till the
moment when the http response is built and sent to the client. Could be less
than a second. Do you anticipate that your directory event will be fired in
the same time? Probably you need to re-think your design.

Eliyahu

"Steven" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
> First, let me state that I am trying to learn asp.net, so I am a

beginner.
> Now on to the issue. I have a webform with a single Textbox and a
> FileSystemWatcher monitoring a directory for OnCreate events. I am trying
> to change the text in response to an OnCreate event. I would like to

change
> the Forecolor to red, from black. Apparently, this is not as easy to do

as
> in vb.net. I have tried the direct approach in the OnCreate event;
> "Textbox1.Forecolor = Color.Red". This produces no results. I have tried
> applying a style to the Textbox, no results. Server.Tranfer to another

page
> produces a "Object not set to an instance" error. Server.Transfer to the
> same page does nothing. What do I need to do to accomplish this simple
> task?
>
> Thanks,
> Steven
>
>



 
Reply With Quote
 
Steven
Guest
Posts: n/a
 
      03-29-2005
First, thank you for your replies. I am building a demo where the user will
stay at the same page until the OnCreate event fires then navigate to
another page, then back to the original page with a new FileSystemWatcher.
The user can control when the OnCreate event is fired. All I am trying to
do is to relay to the user, in some way, that the OnCreate event has
occurred.
I am open to suggestions on how to do this.

"Eliyahu Goldin" <(E-Mail Removed)> wrote in message
news:eq6oU$(E-Mail Removed)...
> Steven,
>
> Putting FileSystemWatcher on a web form doesn't make much sense. A web

form
> lives very short time, from the moment when an http request arrives till

the
> moment when the http response is built and sent to the client. Could be

less
> than a second. Do you anticipate that your directory event will be fired

in
> the same time? Probably you need to re-think your design.
>
> Eliyahu
>
> "Steven" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hello,
> > First, let me state that I am trying to learn asp.net, so I am a

> beginner.
> > Now on to the issue. I have a webform with a single Textbox and a
> > FileSystemWatcher monitoring a directory for OnCreate events. I am

trying
> > to change the text in response to an OnCreate event. I would like to

> change
> > the Forecolor to red, from black. Apparently, this is not as easy to do

> as
> > in vb.net. I have tried the direct approach in the OnCreate event;
> > "Textbox1.Forecolor = Color.Red". This produces no results. I have

tried
> > applying a style to the Textbox, no results. Server.Tranfer to another

> page
> > produces a "Object not set to an instance" error. Server.Transfer to

the
> > same page does nothing. What do I need to do to accomplish this simple
> > task?
> >
> > Thanks,
> > Steven
> >
> >

>
>



 
Reply With Quote
 
Kevin Spencer
Guest
Posts: n/a
 
      03-29-2005
> I am open to suggestions on how to do this.

Well, you already have mine.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"Steven" <(E-Mail Removed)> wrote in message
news:uR$(E-Mail Removed)...
> First, thank you for your replies. I am building a demo where the user
> will
> stay at the same page until the OnCreate event fires then navigate to
> another page, then back to the original page with a new FileSystemWatcher.
> The user can control when the OnCreate event is fired. All I am trying to
> do is to relay to the user, in some way, that the OnCreate event has
> occurred.
> I am open to suggestions on how to do this.
>
> "Eliyahu Goldin" <(E-Mail Removed)> wrote in message
> news:eq6oU$(E-Mail Removed)...
>> Steven,
>>
>> Putting FileSystemWatcher on a web form doesn't make much sense. A web

> form
>> lives very short time, from the moment when an http request arrives till

> the
>> moment when the http response is built and sent to the client. Could be

> less
>> than a second. Do you anticipate that your directory event will be fired

> in
>> the same time? Probably you need to re-think your design.
>>
>> Eliyahu
>>
>> "Steven" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > Hello,
>> > First, let me state that I am trying to learn asp.net, so I am a

>> beginner.
>> > Now on to the issue. I have a webform with a single Textbox and a
>> > FileSystemWatcher monitoring a directory for OnCreate events. I am

> trying
>> > to change the text in response to an OnCreate event. I would like to

>> change
>> > the Forecolor to red, from black. Apparently, this is not as easy to
>> > do

>> as
>> > in vb.net. I have tried the direct approach in the OnCreate event;
>> > "Textbox1.Forecolor = Color.Red". This produces no results. I have

> tried
>> > applying a style to the Textbox, no results. Server.Tranfer to another

>> page
>> > produces a "Object not set to an instance" error. Server.Transfer to

> the
>> > same page does nothing. What do I need to do to accomplish this simple
>> > task?
>> >
>> > Thanks,
>> > Steven
>> >
>> >

>>
>>

>
>



 
Reply With Quote
 
Eliyahu Goldin
Guest
Posts: n/a
 
      03-29-2005
Steven,

Kevin's response is marvelous. Read it slowly and several times.

Eliyahu

"Steven" <(E-Mail Removed)> wrote in message
news:uR$(E-Mail Removed)...
> First, thank you for your replies. I am building a demo where the user

will
> stay at the same page until the OnCreate event fires then navigate to
> another page, then back to the original page with a new FileSystemWatcher.
> The user can control when the OnCreate event is fired. All I am trying to
> do is to relay to the user, in some way, that the OnCreate event has
> occurred.
> I am open to suggestions on how to do this.
>
> "Eliyahu Goldin" <(E-Mail Removed)> wrote in message
> news:eq6oU$(E-Mail Removed)...
> > Steven,
> >
> > Putting FileSystemWatcher on a web form doesn't make much sense. A web

> form
> > lives very short time, from the moment when an http request arrives till

> the
> > moment when the http response is built and sent to the client. Could be

> less
> > than a second. Do you anticipate that your directory event will be fired

> in
> > the same time? Probably you need to re-think your design.
> >
> > Eliyahu
> >
> > "Steven" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > Hello,
> > > First, let me state that I am trying to learn asp.net, so I am a

> > beginner.
> > > Now on to the issue. I have a webform with a single Textbox and a
> > > FileSystemWatcher monitoring a directory for OnCreate events. I am

> trying
> > > to change the text in response to an OnCreate event. I would like to

> > change
> > > the Forecolor to red, from black. Apparently, this is not as easy to

do
> > as
> > > in vb.net. I have tried the direct approach in the OnCreate event;
> > > "Textbox1.Forecolor = Color.Red". This produces no results. I have

> tried
> > > applying a style to the Textbox, no results. Server.Tranfer to

another
> > page
> > > produces a "Object not set to an instance" error. Server.Transfer to

> the
> > > same page does nothing. What do I need to do to accomplish this

simple
> > > task?
> > >
> > > Thanks,
> > > Steven
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Steven
Guest
Posts: n/a
 
      03-29-2005
Thanks again. I have looked at the Meta tag and that is what I would like
to do, but only postback once after the OnCreate event occurs. One
requirement is that the user must be able to navigate around an existing asp
and html website, which I have 'hung' the asp.net app from. I am thinking
that asp.net may not the correct technology solution. I'm not sure what
else to use though.

"Eliyahu Goldin" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Steven,
>
> Kevin's response is marvelous. Read it slowly and several times.
>
> Eliyahu
>
> "Steven" <(E-Mail Removed)> wrote in message
> news:uR$(E-Mail Removed)...
> > First, thank you for your replies. I am building a demo where the user

> will
> > stay at the same page until the OnCreate event fires then navigate to
> > another page, then back to the original page with a new

FileSystemWatcher.
> > The user can control when the OnCreate event is fired. All I am trying

to
> > do is to relay to the user, in some way, that the OnCreate event has
> > occurred.
> > I am open to suggestions on how to do this.
> >
> > "Eliyahu Goldin" <(E-Mail Removed)> wrote in message
> > news:eq6oU$(E-Mail Removed)...
> > > Steven,
> > >
> > > Putting FileSystemWatcher on a web form doesn't make much sense. A web

> > form
> > > lives very short time, from the moment when an http request arrives

till
> > the
> > > moment when the http response is built and sent to the client. Could

be
> > less
> > > than a second. Do you anticipate that your directory event will be

fired
> > in
> > > the same time? Probably you need to re-think your design.
> > >
> > > Eliyahu
> > >
> > > "Steven" <(E-Mail Removed)> wrote in message
> > > news:(E-Mail Removed)...
> > > > Hello,
> > > > First, let me state that I am trying to learn asp.net, so I am a
> > > beginner.
> > > > Now on to the issue. I have a webform with a single Textbox and a
> > > > FileSystemWatcher monitoring a directory for OnCreate events. I am

> > trying
> > > > to change the text in response to an OnCreate event. I would like

to
> > > change
> > > > the Forecolor to red, from black. Apparently, this is not as easy

to
> do
> > > as
> > > > in vb.net. I have tried the direct approach in the OnCreate event;
> > > > "Textbox1.Forecolor = Color.Red". This produces no results. I have

> > tried
> > > > applying a style to the Textbox, no results. Server.Tranfer to

> another
> > > page
> > > > produces a "Object not set to an instance" error. Server.Transfer

to
> > the
> > > > same page does nothing. What do I need to do to accomplish this

> simple
> > > > task?
> > > >
> > > > Thanks,
> > > > Steven
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple VB.Net / webservice requirement (but not simple for me....) Dave E ASP .Net 7 01-11-2006 02:07 PM
Simple Question - Simple Answer? Daniel Frey XML 4 01-12-2005 04:25 PM
Re: Simple Simple question!!! Kevin Spencer ASP .Net 0 06-25-2004 05:25 PM
Re: Simple Simple question!!! ashelley@inlandkwpp.com ASP .Net 0 06-25-2004 04:18 PM
Simple problem with a simple chat script dillon Javascript 1 11-17-2003 11:11 PM



Advertisments