473,398 Members | 2,188 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Make label invisible when textbox empty

Hello -

I have a page that runs a stored procedure checking for the existence of a
name in a database. If it exists, lblMessage returns text indicating same.

When a user goes back and clears the textbox, I would like the message to
disappear, instead of waiting for a return trip to the server.

Any suggestions will be greatly appreciated!
--
Sandy
Nov 19 '05 #1
3 6001
Sandy,

Setup a client side onchange event for the textbox. In the event check if
the textbox is empty and hide the label.

The javascript event handler will look like this:

function onchange(){
if (myTextBox.value == "") myLabel.style.display="hidden";}

Eliyahu

"Sandy" <Sa***@discussions.microsoft.com> wrote in message
news:FB**********************************@microsof t.com...
Hello -

I have a page that runs a stored procedure checking for the existence of a
name in a database. If it exists, lblMessage returns text indicating same.
When a user goes back and clears the textbox, I would like the message to
disappear, instead of waiting for a return trip to the server.

Any suggestions will be greatly appreciated!
--
Sandy

Nov 19 '05 #2
Hi Eliyahu!

Thanks for your response. I am having trouble hooking it up. I put the
script in the html and tried:
<asp:textbox id=txtUserName ontextchanged="onchange" runat="server"
Width="100%"></asp:textbox>

I need to connect it with something in the vb code though, don't I?
--
Sandy
"Eliyahu Goldin" wrote:
Sandy,

Setup a client side onchange event for the textbox. In the event check if
the textbox is empty and hide the label.

The javascript event handler will look like this:

function onchange(){
if (myTextBox.value == "") myLabel.style.display="hidden";}

Eliyahu

"Sandy" <Sa***@discussions.microsoft.com> wrote in message
news:FB**********************************@microsof t.com...
Hello -

I have a page that runs a stored procedure checking for the existence of a
name in a database. If it exists, lblMessage returns text indicating

same.

When a user goes back and clears the textbox, I would like the message to
disappear, instead of waiting for a return trip to the server.

Any suggestions will be greatly appreciated!
--
Sandy


Nov 19 '05 #3
Sandy,

ontextchanged is a server-side event. You need the client side onchange one.
That is:

<asp:textbox id=txtUserName onchange="onchange();" runat="server"
Width="100%"></asp:textbox>

vb code is on the server side. Your task is a client-side one. In ASP.NET
You need to have clear understanding what belongs to server and what to
client.

Eliyahu

"Sandy" <Sa***@discussions.microsoft.com> wrote in message
news:9F**********************************@microsof t.com...
Hi Eliyahu!

Thanks for your response. I am having trouble hooking it up. I put the
script in the html and tried:
<asp:textbox id=txtUserName ontextchanged="onchange" runat="server"
Width="100%"></asp:textbox>

I need to connect it with something in the vb code though, don't I?
--
Sandy
"Eliyahu Goldin" wrote:
Sandy,

Setup a client side onchange event for the textbox. In the event check if the textbox is empty and hide the label.

The javascript event handler will look like this:

function onchange(){
if (myTextBox.value == "") myLabel.style.display="hidden";}

Eliyahu

"Sandy" <Sa***@discussions.microsoft.com> wrote in message
news:FB**********************************@microsof t.com...
Hello -

I have a page that runs a stored procedure checking for the existence of a name in a database. If it exists, lblMessage returns text indicating

same.

When a user goes back and clears the textbox, I would like the message to disappear, instead of waiting for a return trip to the server.

Any suggestions will be greatly appreciated!
--
Sandy


Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Ed West | last post by:
Hello, I have a simple form with some input boxes. After validation if one fails, then I would like to at the top of the page say something like "The following fields in red are required" and...
1
by: Venki | last post by:
I have a textbox to enter an email address followed by a telephone textbox. The email has a regularexpressionvalidator and a requiredfieldvalidator. The ReqField works fine, but if I put in an...
6
by: Selden McCabe | last post by:
I have a form with a bunch of image buttons. When the user moves the mouse over a button, I want to do two things: 1. change the Imagebutton's picture, and 2. make another control visible. I'm...
2
by: dik | last post by:
Hi I have a lot of rows in my page (see below a sample). How can I make 3 rows invisible/visible at the same time in a group instead of row for row? Is this possible? <asp:Table id="Table1"...
4
by: NH | last post by:
Hi, I just cannot get this to work. I want to make a cell editable in a datagrid only if the value of another cell is something specific. I am able to capture the value of the other cell via the...
16
by: Miguel Dias Moura | last post by:
Hello, i have 5 panels in an ASP.net / VB page. The panel 1 is visible the other 4 are NOT visible. I also have 5 images: image 1, image 2, ..., image5. When i click one of the images,...
3
by: rockdale | last post by:
Hi, All: I have a datagrid with TemplateColumn as following: <asp:TemplateColumn Visible="False" > <ItemStyle Width="0px"></ItemStyle> <ItemTemplate> <asp:Label id="lblMin_Value"...
9
by: Mel | last post by:
I have 10 columns total. 3 of them are invisible. The rest are read- only BoundFields, 3 of which are editable fields using TemplateFields. Upon editing, I want to validate what the user enters...
13
by: pvong | last post by:
VB.Net I'm pulling Data from a DB and creating a letter by filling the Labels. It works perfectly, but if Addr2 and Addr3 are blank, it leaves a Blank space in that area. Is there a way to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.