A
Alex Nitulescu
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
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