Attribute 'onchange' is not a valid attribute of element 'TextBox'

J

Joe Kovac

Hi!

Using:

<asp:TextBox ID="TextBox1" runat="server"
onchange="onchange()"></asp:TextBox>

I get:

Warning 1 Validation (ASP.Net): Attribute 'onchange' is not a valid
attribute of element 'TextBox'.

How to avoid this warning? What should I do to "fix" it?

Possibly you styles or like that???

Thanks

Joe
 
M

Mark Rae

Using:

<asp:TextBox ID="TextBox1" runat="server"
onchange="onchange()"></asp:TextBox>

I get:

Warning 1 Validation (ASP.Net): Attribute 'onchange' is not a valid
attribute of element 'TextBox'.

That's because you're using a webcontrol, which doesn't have an onchange
method.
How to avoid this warning? What should I do to "fix" it?

In code-behind:

TextBox1.Attributes.Add("onchange", "onchange();");

Also, see my previous message advising against this... :)
 
J

Joe Kovac

Mark said:
That's because you're using a webcontrol, which doesn't have an onchange
method.


In code-behind:

TextBox1.Attributes.Add("onchange", "onchange();");

I guess this way MS wants to point out clearly, that you use non MS
properties. Putting it to the .aspx page works, but produces a not
beautiful warning.

Also, see my previous message advising against this... :)

See my comment on your comment of your previous message ;-)
 

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

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top