|
I wanna allow only number for my TextBox1.Its can only insert 7 digits.If I enter "23ddddd" on my TextBox1 i wanna give an error message for that.So please help me...........
CheeN
|
|
|
|
|
In the Keypress event handler check if the pressed key is digit or not. If not set handled to true. Don't forget backspace key.
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
Can i use regular expression or any validater?If yes how can i use that..?
i tried
Match MatchTelNum = Regex.Match(tel.Text, "[a-z&0-9]*");
Its wroks.But i had a problem coz if i entered "3333333" to that textBox1.It also giv an error message.If you can help me..
ReagrDzzz
CheeN
|
|
|
|
|
sacr83 wrote: Match MatchTelNum = Regex.Match(tel.Text, "[a-z&0-9]*");
Its wroks.
No, it does not work...
That will match letters and digits and '&'.
|
|
|
|
|
hey
use a maskedTextBox instead of a notmal textBox
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
Cheen
on Press key Event of textbox
use this code
if (Char.IsLetter(e.KeyChar))
{
e.Handled;
}
wasim khan
|
|
|
|
|
wasimsharp wrote: if (Char.IsLetter(e.KeyChar))
{
e.Handled;
}
1. That wont compile.
2. Are you checking for digits or letters?
|
|
|
|
|
No
if (!Char.IsDigit(e.KeyChar))
{
e.Handled = true;
}
wasim khan
|
|
|
|
|
int.TryParse in the key event handler is your friend.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Greeeg wrote: int.TryParse in the key event handler is your friend.
Friends dont let friends overflow! What happens if the person enters 25 digits?
|
|
|
|
|
Then I should take the time to read the question more precisely
A regex like \d{,7} for at most, or \d{7} for exactly 7 digits will do the job as well.
But I'd use a NumericUpDown control for this task.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
sacr83,
If you only want to allow numbers, why not use a NumericUpDown control...
MSDN[^]
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
Just use this
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)<br />
{<br />
if (!char.IsDigit(e.KeyChar))<br />
{<br />
e.Handled = true;<br />
MessageBox.Show("Integer numbers only");<br />
} <br />
}
|
|
|
|
|
if you want to get an error as you type you can use KeyDown events then get your last entered character from your textbox, if last character is not what you suggest to input throw an errror
|
|
|
|
|
Hello!
I´ve made a customError-class inheriting from BaseValidator which I use to add error to Page.Validators from code-behind.
public class CustomError : BaseValidator
At first I inherited from IValidator , but I had to be able to set ValidationGroup and so I switched to BaseValidator . Problem is now the PropertiesValid-property of my class always throws an object reference-error. I´m giving ControlToValidate a correct value, so thats not whats causing this. Does anyone have an idea why this error occurs and how I prevent it?
The error looks like this:
[NullReferenceException: Objectreference has not been set to an instance of an object.]
[NullReferenceException: Objectreference has not been set to an instance of an object.]
System.Web.UI.WebControls.BaseValidator.CheckControlValidationProperty(String name, String propertyName) +23
System.Web.UI.WebControls.BaseValidator.ControlPropertiesValid() +37
System.Web.UI.WebControls.BaseValidator.Validate() +58
|
|
|
|
|
|
hi freinds
now a days i am working to create the System updater.
can i use dll which is downloaded with update. and then my updater just
call the dll and it install the update. just like (DNP .NetPanel)
if yes then plez give me some help that how can i do this.
wasim khan
|
|
|
|
|
The way this usually works is a bootstrapper that runs, closes your app, replaces it with a new version and you're done.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
hi Christian Graus
i am creating System Configurator as i saw Dotnetpanel they have a configurator which download the Update and in the uodate they have setup.dll. which run when we install the update how i can do this.
as i remove the dll before installing the update its give error message while installing the update. i think that all the method that is used to install the new update is inside that dll can u tell me how it work
wasim khan
|
|
|
|
|
Hi! I have a question. I am building a APP and I am working with xml documents, I want to delete the file from the local disk after I will put the data I need in the DB, how should I do that?? Thanks ahead
|
|
|
|
|
File.Delete
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
File.Delete(pathoftheFile)
wasim khan
|
|
|
|
|
this is the exception whan I am getting when I am debugging, and trying to remove the file:
The process cannot access the file 'C:\test.xml' because it is being used by another process.
|
|
|
|
|
it's ok, I fixed it, I had forgotten a XmlReader open, thx for the help and have a nice day
|
|
|
|
|
k thats good and one think remember always share your knowledege becoz some buddy like you and me need it...........................
wasim khan
|
|
|
|