Simple problem

Discussion in 'ASP .Net' started by Steven, Mar 29, 2005.

  1. Steven

    Steven Guest

    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
     
    Steven, Mar 29, 2005
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:...
    > 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
    >
    >
     
    Kevin Spencer, Mar 29, 2005
    #2
    1. Advertising

  3. 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
    >
    >
     
    Marcus Monaghan, Mar 29, 2005
    #3
  4. 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" <> wrote in message
    news:...
    > 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
    >
    >
     
    Eliyahu Goldin, Mar 29, 2005
    #4
  5. Steven

    Steven Guest

    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" <> wrote in message
    news:eq6oU$...
    > 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" <> wrote in message
    > news:...
    > > 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
    > >
    > >

    >
    >
     
    Steven, Mar 29, 2005
    #5
  6. > 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" <> wrote in message
    news:uR$...
    > 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" <> wrote in message
    > news:eq6oU$...
    >> 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" <> wrote in message
    >> news:...
    >> > 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
    >> >
    >> >

    >>
    >>

    >
    >
     
    Kevin Spencer, Mar 29, 2005
    #6
  7. Steven,

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

    Eliyahu

    "Steven" <> wrote in message
    news:uR$...
    > 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" <> wrote in message
    > news:eq6oU$...
    > > 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" <> wrote in message
    > > news:...
    > > > 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
    > > >
    > > >

    > >
    > >

    >
    >
     
    Eliyahu Goldin, Mar 29, 2005
    #7
  8. Steven

    Steven Guest

    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" <> wrote in message
    news:...
    > Steven,
    >
    > Kevin's response is marvelous. Read it slowly and several times.
    >
    > Eliyahu
    >
    > "Steven" <> wrote in message
    > news:uR$...
    > > 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" <> wrote in message
    > > news:eq6oU$...
    > > > 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" <> wrote in message
    > > > news:...
    > > > > 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
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    Steven, Mar 29, 2005
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    575
  2. Kevin Spencer

    Re: Simple Simple question!!!

    Kevin Spencer, Jun 25, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    678
    Kevin Spencer
    Jun 25, 2004
  3. Dave E
    Replies:
    7
    Views:
    760
    Josh Twist
    Jan 11, 2006
  4. Daniel Frey

    Simple Question - Simple Answer?

    Daniel Frey, Dec 28, 2004, in forum: XML
    Replies:
    4
    Views:
    858
    Daniel Frey
    Jan 12, 2005
  5. dillon
    Replies:
    1
    Views:
    185
    higabe
    Nov 17, 2003
Loading...

Share This Page