Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 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 February 5th, 2005, 03:24 PM
Authorized User
 
Join Date: Jan 2005
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default Formatting text

Hello,

I know when you do Resoponse.Write you can pass a paramter like so to format the text for a specific type:

Response.Write(TheCost(c));

or something like that. Is there a way to achieve the same result when assigning the .Text propert of a control?

-- Jenni
 
Old February 5th, 2005, 04:36 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

when you call ToString() method you can format your string,
Code:
[C#]
int MyInt = 100;
String MyString = MyInt.ToString("C");
Console.WriteLine(MyString);
[Visual Basic]
Dim MyInt As Integer = 100
Dim MyString As String = MyInt.ToString("C")
Console.WriteLine(MyString)
take a look into MSDN.

_____________________________
Mehdi.
software engineering student.
Looking for a good job for summer 2005.
 
Old February 5th, 2005, 05:02 PM
Authorized User
 
Join Date: Jan 2005
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your reply!

I checked out the MSDN Format Specifiers topic and it was very helpful. Both your example and the MSDN example show the usage of the format specifier as

[C#]
MyInt.ToString("C");

but the compiler kicks back the following message:

No overload for method 'ToString' takes '1' arguments

Here is my exact code:

OnlinePrice.Text = h["OnlinePrice"].ToString("C");

Do you see something wrong?


 
Old February 6th, 2005, 06:35 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

I don't know about h["OnlinePrice"].I guess it's an object type,so you should convert it to int type explicitly,
Code:
OnlinePrice.Text = ((int)h["OnlinePrice"]).ToString("C");
because there is just one method(without any parameter) for Object.ToString, so compiler complains about that.

_____________________________
Mehdi.
software engineering student.
Looking for a good job for summer 2005.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Write in A DOC File With Same Text Formatting Arshi VB How-To 0 February 5th, 2006 05:08 AM
Formatting a text box alantodd Access VBA 3 December 14th, 2004 05:59 PM
text formatting question dadoonan BOOK: Beginning ASP 3.0 1 November 15th, 2004 02:12 AM
PHP formatting input text shahchi1 Pro PHP 2 June 9th, 2004 04:18 PM
MYSQL Query text Formatting yourcompadre Beginning PHP 1 May 12th, 2004 06:55 AM





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