473,664 Members | 3,035 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6010
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.valu e == "") myLabel.style.d isplay="hidden" ;}

Eliyahu

"Sandy" <Sa***@discussi ons.microsoft.c om> wrote in message
news:FB******** *************** ***********@mic rosoft.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.valu e == "") myLabel.style.d isplay="hidden" ;}

Eliyahu

"Sandy" <Sa***@discussi ons.microsoft.c om> wrote in message
news:FB******** *************** ***********@mic rosoft.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="oncha nge();" 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***@discussi ons.microsoft.c om> wrote in message
news:9F******** *************** ***********@mic rosoft.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.valu e == "") myLabel.style.d isplay="hidden" ;}

Eliyahu

"Sandy" <Sa***@discussi ons.microsoft.c om> wrote in message
news:FB******** *************** ***********@mic rosoft.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
8957
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 then change the label in front of the textbox or dropdown list to red... is this possible with asp.net? It seems you can only put a RequiredFieldValidator on the page, and if it fails validation then that text is displayed... ? Thanks
1
1897
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 invalid email addy then click in the telephone field below, something very odd happens. The telephone label & textbox (and all controls below) shift down one line, and rather than having my cursor in the telephone textbox. The cursor is in the...
6
14688
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 using the Imagebutton.Attributes.Add("onMouseOver","this.src = 'somepicture.jpg') and that works fine. I've tried some java script to change the other control's visible property by changing is className, but that doesn't seem to work
2
1567
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" runat="server" Width="824px" Height="248px"> <asp:TableRow> <asp:TableCell ColumnSpan="4"> <asp:Label id="lbl2" Runat="server"></asp:Label></b> </asp:TableCell> </asp:TableRow>
4
2469
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 ItemDataBound event of the datagrid e.g. If e.Item.Cells(8).Text = "2" Then 'Make the textbox defined in my edititemtemplate read only of invisible End If
16
11547
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, image N, the panel N becomes visible and all the other invisible.
3
2885
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" Visible=False runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.min_value") %>'> </asp:Label>
9
4781
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 against one of those invisible columns. How do I accomplish this? The code below that I attempted just returns an empty string when I try to retrieve the invisible column data: gvParts.Rows(e.RowIndex).Cells(8).Text
13
1446
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 make it so I can say if the data is empty, temporarely delete the label or make it not exist at all? I'm not talking about just hiding it because it still leaves an empy space. This is what I get: FirstName LastName
0
8348
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8861
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8778
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8636
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7375
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5660
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4185
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2003
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1759
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.