asp.net page view

E

ervin

I developed an application that search a db. I have a
search page that has textbox, command button, and label.
when the user enter nothing in the textbox and hit the
button, the label will display an error. How can I change
the label text to nothing when the user enters something
in the textbox or when the user use the back arrow to go
back to the search form.


thanks
 
S

Steve C. Orr, MCSD

In your button click event put some code like this:

If MyTextBox.Text.Length>0 Then MyLabel.Text=""
 
M

MS News \(MS ILM\)

You might want to use JavaScript:
in the TextBox1-OnFocus event you clear the Label
 
S

Sreejumon[MVP]

Hi,

If you want to clear the label text while editing the
textbox, you have to use Javascript (onchange) event for
the textbox.
Also call the same method from body onload, so that while
clicking the back button that will be cleared.

Please consider the label name is asp.net getenrated
page..you can use the following lines...
var controls = document.getElementsByTagName('INPUT');
for (var i=0; i<controls.length; i++)
{
if (controls.type=="text")
{
var qnty = controls.value;
if(controls.name.substring(n,n)=="your text name")

Let me know if you need help.

regards
Sreejumon[MVP]
www.mstechzone.com
 

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
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top