473,412 Members | 2,294 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Validation - substitution of null with "0"

Pao
I have to validate some textboxes.
The rule is that only numbers and null values are good.
But in case of null values, I have to substitute them with "0".

How can I do? thanks

Dec 27 '06 #1
2 1250
"Pao" wrote ...
But in case of null values, I have to substitute them with "0".
How can I do? thanks
Hey,

You didn't mention whether this was going to be client or server side, but
something along these lines...

If txtMyTextBox.Text = String.Empty Then

txtMyTextBox.Text = "0"

End If

You should be able to adapt this quite easily to iterate through the
textboxes on the page perhaps by iterating through the form and thus remove
the dependancy to know the name of each text box.

I don't tend to dabble client side, but I'm sure something similar would be
possible with javascript, and again, iterating through.

HTH

Regards

Rob
Dec 27 '06 #2
Pao

Rob Meade ha scritto:
"Pao" wrote ...
But in case of null values, I have to substitute them with "0".
How can I do? thanks

Hey,

You didn't mention whether this was going to be client or server side, but
something along these lines...

If txtMyTextBox.Text = String.Empty Then

txtMyTextBox.Text = "0"

End If
Thank you Rob, I have to do that server side, but I can't do like your
example as I use a formview control bounded to an objectdatasource.
So when I have some textboxes with no values, and the property of my
object is Int, it generates an error.
I tried to intercept some event like OnInserting, but in the code I
can't reach the textboxes of the ItemTemplate.
For this reason I want prevent the problem by validating the textboxes,
but in case of null how can I put a "0" ? I read somewhere that regular
expressions can also substitute values but wasn't teached how...

Dec 28 '06 #3

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

Similar topics

1
by: Mike | last post by:
Note: My XML experience to date has (unfortunately) been limited to reading and thinking, rather than implementation. Anyway, I am in the process of trying to figure out the most efficient way...
1
by: Ghee | last post by:
Hello, I have a (java) DOM object that adheres to an XML schema. I want to manipulate it in code, but to ensure that the object still sticks to the schema (ie, validation during the life-cycle...
13
by: Don Vaillancourt | last post by:
What's going on with Javascript. At the beginning there was the "undefined" value which represented an object which really didn't exist then came the null keyword. But yesterday I stumbled...
13
by: gary | last post by:
Hi, We all know the below codes are dangerous: { int *p = new int; delete p; delete p; } And we also know the compilers do not delete p if p==NULL. So why compilers do not "p = NULL"...
1
by: charliewest | last post by:
Is it possible to use the custom validation control to validate a calendar control via client-side script (in jscript)? I'm familiar with custom validation and client side script, and i am aware...
14
by: MuZZy | last post by:
Hi, Lately i've been (and still am) fixing some memory leaks problems in the project i just took over when i got this new job. Among the other issues i've noticed that for localy created objects...
2
by: MegaC | last post by:
Greetings, I am getting rather famiilar with RSS., but I still have a few questions. I set up my RSS link at http://www.ottawa-theologyontap.com/rss/latest_resources.xml, but when I use a...
3
by: Adam Clauss | last post by:
I'm running into a problem with schema validation. For some reason, if a schema has an xs:all section to it, it does not validate correctly. It seems to treat it as a sequence. My understanding...
5
RMWChaos
by: RMWChaos | last post by:
I am working on a script to create and remove DOM elements, and I want to make it as efficient as possible (no redundancies). Because DOM elements each have their own set of attributes, the function...
3
by: mdfidahussain | last post by:
Hello VB Experts, I've encountered an error -> "SWbemServicesEx: Quota Validation" while executing a VB Script, infact the script is simple and is also running fine for many servers but only...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...
0
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...

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.