Wrox Programmer Forums
|
Visual Web Developer 2005 Discuss creating ASP.NET 2.0 sites with Microsoft's Visual Web Developer 2005. If your question is more specific to a piece of code than the Visual tool, see the ASP.NEt 2.0 forums instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Web Developer 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 18th, 2010, 01:29 AM
Authorized User
Points: 410, Level: 7
Points: 410, Level: 7 Points: 410, Level: 7 Points: 410, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2009
Posts: 72
Thanks: 17
Thanked 0 Times in 0 Posts
Question TextBox Default Value Issue

Hi,

I have a Textbox in which I am showing a default value - "KGS".

When the User clicks the Textbox that Default value is gone & then user can Type his own value.

This TextBox had no validation.

Now My issue is that , I have to insert this value in database. This is a big form. SO, if the User doesn't Enter any value in the Textbox, then the default value i.e "KGS" goes into database. I don't want this.

What I want is, If the User enters nothing into the TextBox, then " " emty string should go to database & not the Value "KGS".

Following is the code -

<asp:TextBox ID="PD_weight" runat="server" Text="KGS" size="15" onFocus="if (value == 'KGS') {value=''}" onblur="if (value== '') {value='KGS'}" MaxLength="4"></asp:TextBox>

How this can be done?


Thank You.....!!
 
Old June 18th, 2010, 02:45 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Looks like you're not really using a *default value* (which would be stored in the database), but a UI hint instead, right? If so, take a look at watermarking:

http://www.asp.net/ajax/ajaxcontrolt...Watermark.aspx
http://www.google.com/#hl=en&source=...0c9c088323bced

It just displays the text at the client, but doesn't really see it as a value.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Code for Chpt.2-Wrox File Share is missing Default.aspx and Default.aspx.vb bzoni BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 1 October 23rd, 2009 02:39 PM
Set Default text in a textbox to whats in the prev marcin2k Access VBA 1 September 19th, 2005 08:55 AM
Autosuggest Textbox Issue smay Javascript 3 August 3rd, 2005 02:25 PM
Default Paging Issue Jeff1218 Classic ASP Databases 2 March 4th, 2005 05:27 AM
Masked TextBox & formatting TextBox melvik C# 1 September 22nd, 2003 11:01 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.