Inherited TextBox

S

Sehboo

All,

I want to create a custom control which is actually inherited from a
textbox. This custom control will have one more field called
Required. If requires is set to TRUE then before user can post this
page (by clicking button or something), I want to make sure that text
field is not empty. If it is empty then I want to throw an exception.

I am not sure how to achieve this. I know how to inherit controls.

Any help is appreciated.

Thanks
 
V

Victor Garcia Aprea [MVP]

Hi Sehboo,

You will need to output some javascript code from your custom control in
order to intercep the form submission and only allow it if the textbox value
is not empty. Regarding your req to throw an exception, do you mean for
devices not supporting javascript in which case the textbox's value may be
posted emtpy? If so, from your custom control you could check that value and
throw an exception right away...

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx

To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
 

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,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top