Connecting Tech Pros Worldwide Forums | Help | Site Map

ASP C# Itemtable cell money format

Daxthecon's Avatar
Member
 
Join Date: Jul 2008
Location: somewhere between here and there
Posts: 65
#1: Oct 9 '08
Hey guys long time no see. Anyway I was asked to take care of a small issue with one of the item tables I worked on. The issue is that they want it to autoformat to ####.## if applicable. Such as if they just put in 2342 and no "." then the code formats it in there for them adding .00 to the end.

I have searched the net and haven't come up with a solution that caters to my needs. I've found move this around and such but never the completely right solution. If anyone's got an idea to where to find the answer or has an example of the answer I'd be more than appreciated. Thank you for your time.

Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,133
#2: Oct 9 '08

re: ASP C# Itemtable cell money format


Check out the AJAX Toolkit's FilteredTextBox. If this doesn't suit your needs you're probably going to have to write some JavaScript and apply it to the text box to filter/mask the user's input.

-Frinny
Daxthecon's Avatar
Member
 
Join Date: Jul 2008
Location: somewhere between here and there
Posts: 65
#3: Oct 9 '08

re: ASP C# Itemtable cell money format


Is the js method used via putting it in via the asp as a getelementid or how is that put in. I've never had to ues ASP to do this. So I'm a little new to this method.
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,133
#4: Oct 9 '08

re: ASP C# Itemtable cell money format


Quote:

Originally Posted by Daxthecon

Is the js method used via putting it in via the asp as a getelementid or how is that put in. I've never had to ues ASP to do this. So I'm a little new to this method.


If you create your own JS to filter the TextBox data you could pass the whole textbox into the function...so that you don't have to use the getElementByID method (that's what I'm assuming you were trying to say?).

I'm not exactly sure what you're asking.

-Frinny
Daxthecon's Avatar
Member
 
Join Date: Jul 2008
Location: somewhere between here and there
Posts: 65
#5: Oct 9 '08

re: ASP C# Itemtable cell money format


Would I put the javascript into the ASP code at the top and call the element id and then apply the filter to it?
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,133
#6: Oct 9 '08

re: ASP C# Itemtable cell money format


Quote:

Originally Posted by Daxthecon

Would I put the javascript into the ASP code at the top and call the element id and then apply the filter to it?


Ok I take it that the FilterControl is not acceptable for you.

There are a number of different ways to go about adding the JavaScript to your ASP code. You could write an external JS file and include it in your <head> section.

Check out this article on how to check if a text box contains a number.

The article does not mention any use of ScriptManagers or ScriptManagerProxies as it was written before these became main stream.

If you are using a ScriptManager in your application let me know and I'll see if I can help step you through the process.

-Frinny
Daxthecon's Avatar
Member
 
Join Date: Jul 2008
Location: somewhere between here and there
Posts: 65
#7: Oct 9 '08

re: ASP C# Itemtable cell money format


I'm only familiar with putting <script>jarble</script> on top of the ASP.NET Page. Like I said I am realy new to this ASP.net Javascript business.
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,133
#8: Oct 9 '08

re: ASP C# Itemtable cell money format


Quote:

Originally Posted by Daxthecon

I'm only familiar with putting <script>jarble</script> on top of the ASP.NET Page. Like I said I am realy new to this ASP.net Javascript business.


Welcome to the fun side of life :D


Anyways, did you create an Ajax Enabled web site?
If so I think it'd be easiest for you to use the Ajax Tool Kit that I linked you to...this would require the least amount of work.

If not, just put the JavaScript code in <head> section of the page for now so that you can get this done quickly. Use the concepts outlined in the "how to check if a textbox contains a number" article to apply your JavaScript to your TextBox. (Remember to pass the ClientID of the TextBox to the function if your JS function is using the GetElementByID method....)

If you get stuck, post what you've tried so far.

-Frinny
Daxthecon's Avatar
Member
 
Join Date: Jul 2008
Location: somewhere between here and there
Posts: 65
#9: Oct 9 '08

re: ASP C# Itemtable cell money format


Ok will do. Thank you very much for your help.
Reply