JavaScript for OnTextChanged event.

Discussion in 'ASP .Net' started by Alex Nitulescu, Mar 5, 2005.

  1. Hi.

    I have created a web-based file manager. Now I'd like to watch a folder for
    changes, and when a change occurs I'd like to refresh my page.
    Okay. So I have created a FileSystemWatcher set on the folder I need to
    watch. It works fine. The problem occurs when I need to trigger an automatic
    Refresh.
    So I added two handlers - OnChanged and OnRename, in the same class as my
    filemanager.

    In the handlers I tried to say Response.redirect(mypage) to force the
    refresh, but the error I got was: "Cannot redirect after HTTP headers have
    been sent."

    So I tried to change the text of some textbox instead
    <asp:textbox id="txtFileSystemWatcher"
    OnTextChanged="javascript:RefreshPage();" Visible=true Width=500
    Runat=server></asp:textbox>

    with this handler:
    Private Sub OnChanged(ByVal source As Object, ByVal e As
    FileSystemEventArgs)
    txtFileSystemWatcher.Text = "FileSystemWatcher: " & "File: " &
    e.FullPath & " " & e.ChangeType
    End Sub

    and add an OnTextChanged client-side event-handler which looks like this:

    function RefreshPage() {
    __doPostBack('txtFileSystemWatcher', '');
    }

    which would force the refresh. However, now I have the following error:
    BC30456: 'javascript' is not a member of 'ASP.BrowseFiles_aspx'.

    So I changed the HTML to
    <asp:textbox id="txtFileSystemWatcher" OnTextChanged="RefreshPage()"
    Visible=true Width=500 Runat=server></asp:textbox>
    and now, sure enough, I get
    BC30456: 'RefreshPage' is not a member of 'ASP.BrowseFiles_aspx'.

    I also tried in OnLoad of the page to register the event with
    txtFileSystemWatcher.Attributes.Add("OnTextChanged",
    "javascript:RefreshPage()")
    and
    txtFileSystemWatcher.Attributes.Add("OnTextChanged", "RefreshPage()")

    but it still does not work.

    What am I missing here, please ?

    Thank you, Alex
    Alex Nitulescu, Mar 5, 2005
    #1
    1. Advertising

  2. Alex Nitulescu

    Wilco Bauwer Guest

    1. Don't write stuff like '__doPostBack' yourself, ever. Use
    Page.GetPostBackEventReference instead if you want to get the postback
    function call.
    2. Why not set your textbox's AutoPostBack to true? In that case the
    textbox control will render an onchange client-side eventhandler, which
    will postback if the text was changed.

    ----
    - Wilco Bauwer
    Blog & Custom Controls @ http://wilcoding.xs4all.nl
    Wilco Bauwer, Mar 5, 2005
    #2
    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. mdipiet
    Replies:
    1
    Views:
    1,175
  2. Fred Dag
    Replies:
    1
    Views:
    2,013
    =?Utf-8?B?U2VyZ2V5IFBvYmVyZXpvdnNraXk=?=
    Jan 20, 2006
  3. =?Utf-8?B?UGF1bA==?=

    Textbox with OnTextChanged Event

    =?Utf-8?B?UGF1bA==?=, Jun 14, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    4,011
    =?Utf-8?B?TUFDSCBJSQ==?=
    Jun 14, 2006
  4. Leo

    Can I use OnTextChanged in JavaScript for TextBox

    Leo, Nov 18, 2003, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    216
    Jon Paugh
    Nov 18, 2003
  5. Paul

    Textbox and onTextChanged Event

    Paul, Jun 14, 2006, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    223
    Balasubramanian Ramanathan
    Jun 14, 2006
Loading...

Share This Page