Simple, I assume, Javascript question.... The code looks fine, andthe problem eludes me.

A

Alex

Hi. I have this html

<body scroll="auto">
<form id="Ratings" runat="server">

<asp:ScriptManager ID="ScriptManager1" runat="Server"
EnableScriptGlobalization="true" EnableScriptLocalization="true" />

<div align="center">
<br />
<asp:Table
ID="tblFilterBy"
Width="40%"
.......
runat="server" >
<asp:TableHeaderRow runat="server">
<asp:TableHeaderCell Font-Bold="false" ForeColor="#000000"
ColumnSpan="3" runat="server">
<font style="font-size:medium; font-weight:bold">
Filter list by...
</font>
</asp:TableHeaderCell>
</asp:TableHeaderRow>
<asp:TableRow ID="TableRow_FilterBy" runat="server">
<asp:TableCell ID="TableCell_FilteryPIN" Width="40%" runat="server"
HorizontalAlign="Center" ToolTip="Filter by PIN" >
<asp:TextBox
Width="25%"
ID="TextBoxFilterByPIN"
CssClass="unwatermarked"
OnTextChanged="javascript:document.forms[0].
['cmdRemoveFilter'].disabled=(this.value=='');"
runat="server"
/>
<br />
<ajaxToolkit:TextBoxWatermarkExtender
ID="TextBoxWatermarkExtender1"
runat="server"
TargetControlID="TextBoxFilterByPIN"
WatermarkText="PIN"
WatermarkCssClass="watermarked"
Enabled="True"
/>
<asp:Button ID="cmdFilter" Width="35%" Text="Filter"
runat="server" ValidationGroup="Filter" />
<br />
<asp:Button ID="cmdRemoveFilter" Width="35%" Text="Show All"
runat="server"/>
</asp:TableCell>
</asp:TableRow>
</asp:Table>

etc, etc, etc.


Now... to me, the line
OnTextChanged="javascript:document.forms[0].
['cmdRemoveFilter'].disabled=(this.value=='');"
looks fine. Still, the compiler says:

C:\Data\...\Ratings\Ratings.aspx(46,0): error BC30456: 'javascript' is
not a member of 'ASP.ratings_aspx'.
C:\Data\...\Ratings\Ratings.aspx(46,0): error BC30451: Name 'document'
is not declared.
C:\Data\...\Ratings\Ratings.aspx(46,0): error BC30203: Identifier
expected.

Sorry, I don't get it - what's wrong with that line ? I simply want to
disable the button "cmdRemoveFilter" if the textbox
"TextBoxFilterByPIN" becomes empty.....

Thank you very much for reading this.
Alex.
 
T

Tom de Neef

Alex said:
Hi. I have this html
Now... to me, the line
OnTextChanged="javascript:document.forms[0].
['cmdRemoveFilter'].disabled=(this.value=='');"
looks fine. Still, the compiler says:

But it has three double-quotes ( " )
Tom
 
P

pr

Alex said:
Now... to me, the line
OnTextChanged="javascript:document.forms[0].
['cmdRemoveFilter'].disabled=(this.value=='');"
looks fine. Still, the compiler says:

C:\Data\...\Ratings\Ratings.aspx(46,0): error BC30456: 'javascript' is
not a member of 'ASP.ratings_aspx'.

I don't know the markup dialect you're using, but I'd still place a
small wager that you don't want that 'javascript:'. That scheme is used
to make a URL out of a piece of script. My guess is OnTextChanged
doesn't want a URL.

Try

OnTextChanged="document.forms[0].[
'cmdRemoveFilter'].disabled=(this.value=='');"
 
L

Lasse Reichstein Nielsen

Alex said:
Hi. I have this html

That's not HTML.
<body scroll="auto">
<form id="Ratings" runat="server">

E.g., runat="server" is not HTML. It is an instruction to the ...
<asp:ScriptManager ID="ScriptManager1" runat="Server"
EnableScriptGlobalization="true" EnableScriptLocalization="true" />

.... apparently ASP enging running on the server to generate some
HTML. I.e., this is an ASP document, which will be interpreted on
the server, not in the web browser.

<asp:TextBox
Width="25%"
ID="TextBoxFilterByPIN"
CssClass="unwatermarked"
OnTextChanged="javascript:document.forms[0].
['cmdRemoveFilter'].disabled=(this.value=='');"
runat="server"
/>

(there should not be a "." between [0] and ['cmdRemoveFilter'])

This asp:TextBox ASP element is interpreted by the server and will
probably generate the HTML element:
<input type="text" id="TextBoxFilterByPIN" class="unwatermarked">
The OnTextChanged event on the ASP element is run on the server
(as specified by the 'runat="server"' attribute). I don't know
how (using AJAX or only on form submission), but its content should
be in a language and about a document model that is understood by
the server.
Instead it appears to be client side Javascript operating on a DOM
model.
Maybe removing the 'runat="server"' attribute will help, but you
should ask someone who knows ASP to get qualified help.


....
Sorry, I don't get it - what's wrong with that line ? I simply want to
disable the button "cmdRemoveFilter" if the textbox
"TextBoxFilterByPIN" becomes empty.....

In HTML with client side javascript, you would have the attribute
onchange="this.form.elements['cmdRemoveFilter'].disabled =
(this.value=='');"

You should never need to write "javascript:" in an HTML page.

/L
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top