473,725 Members | 2,169 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

formating text in a textbox control?

djc
Is there a property or method of the textbox web server control that I can
use to format the text in it a certian way. For example I am displaying a
date value from a database in a text box. It displays like so: mm/dd/yyyy
mm:hh:ss. I 'was' using the .ToShortDateStr ing() function like so:
txtETA.Text = drMain.Item("Es timatedDelivery Date").ToShortD ateString() which
worked great until I came across a database record with NULL for this field.
It seems the best thing to do would be to have something attatched to the
textbox control itself that would control formating of it's own contents.
That way I would not need to add a NULL check before using the
..ToShortDateSt ring() function.

any input would be appreciated. Thanks!
Nov 19 '05 #1
4 1580
Do a null check around it.

if(drMain.Item( "EstimatedDeliv eryDate") != null)
{
txtETA.Text = drMain.Item("Es timatedDelivery Date").ToShortD ateString() ;
}
else
{
txtETA.Text = "";
}
--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"djc" <no***@nowhere. com> wrote in message
news:Oj******** ******@TK2MSFTN GP15.phx.gbl...
Is there a property or method of the textbox web server control that I can
use to format the text in it a certian way. For example I am displaying a
date value from a database in a text box. It displays like so: mm/dd/yyyy
mm:hh:ss. I 'was' using the .ToShortDateStr ing() function like so:
txtETA.Text = drMain.Item("Es timatedDelivery Date").ToShortD ateString()
which
worked great until I came across a database record with NULL for this
field.
It seems the best thing to do would be to have something attatched to the
textbox control itself that would control formating of it's own contents.
That way I would not need to add a NULL check before using the
.ToShortDateStr ing() function.

any input would be appreciated. Thanks!

Nov 19 '05 #2
I would highly recommend turning Option String On.

http://weblogs.asp.net/rchartier/arc.../13/58381.aspx

This would be a compile time error, and you would already have to handle it
differently.

Just like Curt said, you will have to do it in two steps.

if drMain.Item("Es timatedDelivery Date") == DBNull.Value then
txtETA.Text = ""
else
txtETA.Text = CType( drMain.Item("Es timatedDelivery Date" ),
DateTime).ToSho rtDateString()
end if

"djc" <no***@nowhere. com> wrote in message
news:Oj******** ******@TK2MSFTN GP15.phx.gbl...
Is there a property or method of the textbox web server control that I can
use to format the text in it a certian way. For example I am displaying a
date value from a database in a text box. It displays like so: mm/dd/yyyy
mm:hh:ss. I 'was' using the .ToShortDateStr ing() function like so:
txtETA.Text = drMain.Item("Es timatedDelivery Date").ToShortD ateString() which worked great until I came across a database record with NULL for this field. It seems the best thing to do would be to have something attatched to the
textbox control itself that would control formating of it's own contents.
That way I would not need to add a NULL check before using the
.ToShortDateStr ing() function.

any input would be appreciated. Thanks!

Nov 19 '05 #3
djc
ok. Thank you.

"William F. Robertson, Jr." <theman_at_fdrs ucks.com> wrote in message
news:uZ******** ******@TK2MSFTN GP14.phx.gbl...
I would highly recommend turning Option String On.

http://weblogs.asp.net/rchartier/arc.../13/58381.aspx

This would be a compile time error, and you would already have to handle it differently.

Just like Curt said, you will have to do it in two steps.

if drMain.Item("Es timatedDelivery Date") == DBNull.Value then
txtETA.Text = ""
else
txtETA.Text = CType( drMain.Item("Es timatedDelivery Date" ),
DateTime).ToSho rtDateString()
end if

"djc" <no***@nowhere. com> wrote in message
news:Oj******** ******@TK2MSFTN GP15.phx.gbl...
Is there a property or method of the textbox web server control that I can use to format the text in it a certian way. For example I am displaying a date value from a database in a text box. It displays like so: mm/dd/yyyy mm:hh:ss. I 'was' using the .ToShortDateStr ing() function like so:
txtETA.Text = drMain.Item("Es timatedDelivery Date").ToShortD ateString()

which
worked great until I came across a database record with NULL for this

field.
It seems the best thing to do would be to have something attatched to the textbox control itself that would control formating of it's own contents. That way I would not need to add a NULL check before using the
.ToShortDateStr ing() function.

any input would be appreciated. Thanks!


Nov 19 '05 #4
djc
ok. Thank you.

"Curt_C [MVP]" <software_AT_da rkfalz.com> wrote in message
news:eP******** ******@TK2MSFTN GP12.phx.gbl...
Do a null check around it.

if(drMain.Item( "EstimatedDeliv eryDate") != null)
{
txtETA.Text = drMain.Item("Es timatedDelivery Date").ToShortD ateString() ;
}
else
{
txtETA.Text = "";
}
--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"djc" <no***@nowhere. com> wrote in message
news:Oj******** ******@TK2MSFTN GP15.phx.gbl...
Is there a property or method of the textbox web server control that I can use to format the text in it a certian way. For example I am displaying a date value from a database in a text box. It displays like so: mm/dd/yyyy mm:hh:ss. I 'was' using the .ToShortDateStr ing() function like so:
txtETA.Text = drMain.Item("Es timatedDelivery Date").ToShortD ateString()
which
worked great until I came across a database record with NULL for this
field.
It seems the best thing to do would be to have something attatched to the textbox control itself that would control formating of it's own contents. That way I would not need to add a NULL check before using the
.ToShortDateStr ing() function.

any input would be appreciated. Thanks!


Nov 19 '05 #5

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

Similar topics

3
1788
by: Tom | last post by:
Is there any way to use conditional formating to change a control for a field in a continuous form to a textbox, option group or combobox depending on the value of another field on the form? On a continuous form, I need some records to have a textbox, some to have an option group and some to have a combobox in the same field. Thanks, Tom
0
1162
by: Dmitri Manushin | last post by:
Hi all, i have textBox (multiline) i'am enter many words and don't push enter next i push button and text record in database. When i read data from database in table i'am use teg <pre> for save text formating, but i don't push enter in previous example and my table grow in right. How i can solve my problem. Thanks. P.S.
1
1195
by: Hardik Shah | last post by:
Hi, I want to use various formating on text box , like text box gets only neumeric value, or text box can get only no of character. etc. Any hints will be sincerely appreciated. Hardik Shah.
11
11183
by: Ron L | last post by:
I have a barcode scanner which uses a "keyboard wedge" program so that the data it scans comes through as if it was typed on a keyboard. I am trying to have the data in the barcode be displayed in a text box. I know that there are certain control characters embedded in the data that I want to display substitutions for in the text box, for instance I want to replace ASCII character 04 with the string "<EOT>". I have tried doing a simple...
3
9132
by: dmbuso | last post by:
I have a money field defined in a SQL Server 05 database with a value of 49.50. Also, it displays in SQL Server as 49.5000. I have a form in VB.NET 2005 and I'm using the new MaskedTextBox control in Visual Studio. I set the Mask property for the text box to "$999.00". The problem is when I run the form the text box displays "$495.00" and not "$49.50" as one would expect. It it shifting the values left here. How do I fix this? Thanks...
0
1697
by: andytsummers | last post by:
Hi I have tried to implement drag and drop by using the following code but I have several problems. 1. When you put your mouse over selected text the cursor is still the i-beam and therefore does not show that the text can be dragged 2. When pressing the mouse button to start a drag the selected text changes - I know this is cause the code does not initiate the dodragdrop until the mouse leaves the control but if I change this then you...
16
11127
by: Neil | last post by:
I posted a few days ago that it seems to me that the Access 2007 rich text feature does not support: a) full text justification; b) programmatic manipulation. I was hoping that someone might know one way or the other whether that was true or not, or could point me to an article or help text that would. What I have seen so far online and in Access 2007 help seems to confirm the above. But that (or at least (b)) seems incredible that it...
11
7653
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
Hello, I know I sound like a one-note Johnny on this but I'm still looking for a solution. I need to display characters coming in from a serial port or a socket. I also need to be able to type characters into the display myself - but that's not the main issue at this time. I've tried a scrolling multiline text box but once the original viewable area fills up and it starts scrolling the flashing of the entire area drives me nuts. The...
4
936
by: randy.buchholz | last post by:
I am looking for a way to apply a format by data type. For example, I would like to format all dates as {0:d} without having to do each by hand. I am using themes and looked around there but couldn't find anything. Thanks.
0
8752
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
9401
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
9257
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
9113
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
8097
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
6011
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
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3221
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2157
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.