By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,156 Members | 1,026 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,156 IT Pros & Developers. It's quick & easy.

JavaScript for OnTextChanged event.

P: n/a
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
Nov 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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

Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.