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

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top