|
Ithink you just check ca[0]
|
|
|
|
|
gr8 Rahul
Ranjith Stephen
|
|
|
|
|
ranjithlogics wrote: gr8 Rahul
Yes "gr8" indeed as in reading this makes me want to gr8 my forehead with a cheese gr8er.
Specifically
if (Char.IsNumber(ca[i]))<br />
return false;
within a method called IsNumeric - whose purpose is to return true when a string is numeric.
|
|
|
|
|
rah_sin wrote: for (int i = 0; i < ca.Length;i++)
{
if (Char.IsNumber(ca[i]))
return false;
else
return true;
}
This logic is so badly flawed..
1) false is returned if a character is numeric - the purpose of the method was supposed to be returning true if a caracter is numeric
2) It always returns on the first character, rather than checking the whole string is made up of numbers... basically the for loop is useless.
|
|
|
|
|
my aim was not to write codes for u rather to suggest the method
Char.IsNumber();
now its upto u that how can u use it for ur purpose
i think u people are smart enough to write ur ownn logics.
rahul
|
|
|
|
|
As has been hinted, rather badly, by previous posters the way to write an isnumeric method is to iterate over each character in a string checking whether Char.IsNumber is true or char == '.' for every character in the string.
You may want to remove formatting from the number, as often numbers may be separated with a comma (1,000,000) and sometimes numbers are a representation of currency (£100) - you may or may not want these two cases to be treated as valid numerics.
|
|
|
|
|
J4amieC wrote: As has been hinted, rather badly, by previous posters the way to write an isnumeric method is to iterate over each character in a string checking whether Char.IsNumber is true or char == '.' for every character in the string.
You also need to check for '-' in the first char, and that '.' only appears once.
|
|
|
|
|
Hi,
I would like to verify the version information of an installed application in a computer programatically (does any in built class in C# supports this). It would be great if you some one helps in this regard.
Thanks in advance:
Rakesh
Rakesh
|
|
|
|
|
Hi,
this depends on the kind of application you want to check. I dont know any other standard than file versioning (for executables and dlls) which would allow to retrieve such information. If you want to check applications installed by windows installer there is a way to retrieve the information by using wmi if i remember right. All together there is no "in-built" class for such things and as far as i know you will have to create your own classes to retrieve these information.
|
|
|
|
|
Thanks for responding,
My application do not use Windows Installer, so as per you I need to write a class of my own. So I would like to know how can I access these version info in my class, can you be broad in this...
Rakesh
|
|
|
|
|
I've been googling for retrieving the "standard" product version info of a exe/dll and found a forum post pointing to this article. The third example describes how to retrieve the version info by using the windows api (unsafe code). It's a bit complex but pretty self-explanatory. let me know if you don't get it and good luck so far
MSDN - C# Unsafe Code Tutorial
|
|
|
|
|
Hi!
In this case you can use the AssemblyName.Version property.
If you have the path to your assembly (doesn't matter if it's an exe or a dll), you can call AssemblyName.GetAssemblyName(pathToAssembly); to retrieve the AssemblyName instance.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
In My Application I have Three textboxes for phone number to maintain the format as 3-3-4.Once the user enters the first 3 numbers of a phone number the focus should automatically go to nextbox How can I do it in C#
chanti
|
|
|
|
|
on the textbox1 keyup event u can check the length of text entered in textbox
by following way textbox1.text.length and then check the condition
if(textbox1.text.length==3)
textbox2.focus();
same way you can put same condition for textbox2 on its keyup event
to transfer focus on textbox3.
rahul
|
|
|
|
|
Hi,
you could do this by binding the textboxes KeyUp-Event. The first argument passed to the eventhandler is the triggering object (in this case the textbox where the user has written in). the code for the eventhandler could look like:
TextBox mytxtbox = (TextBox) sender;
if (mytxtbox.Text.Length == 3)
theNextTextBox.Focus();
if you need further assistance feel free to ask
|
|
|
|
|
hi Chanti,
You can do this by more than one way. The most easy way that I could think of right now is to set the maximum lenght property of the three text boxes (lets say firstTextBox, secondTextBox, thirdTextBox) to 3-3-4 simultanuously.
After doing so the program want allow u to type more than 3 digits in the first text box but wont take u to the next one. So u have to fire an event of that text box. The event that u should fire is the TextChanged event and write inside this method the following code:
if (firstTextBox.Text.Length == 3)
{
secondTextBox.Focus();
}
This will take the focus and the next character to the secondTextBox. And u can do this for the other textboxes too.
If you need any help in any other issue, don't be shy to add me at the following MSN address: jamilaboukhalil@hotmail.com or you can just send a mail.
Jamil Abou khalil
|
|
|
|
|
yes this is right solution
the previous one does fail when we keep the key pressed
|
|
|
|
|
then you should use the keypressed value
if there already are 3 characters in the textbox set e.Handled to true and set focus to the next textbox otherwise allow it to write the value
|
|
|
|
|
Yea right, that's the negative side about the keydown/keyup/keypressed events.u don't know which key is pressed.
Anyway hope that i did benifit u.
Feel free to contact me at my MSN address jamilaboukhalil@hotmail.com.
Take care
|
|
|
|
|
Hi,
I am using a simple popup application in which I popup a window and the window will write the value into the parent window text box.
child.aspx
function Fillvalue()
{
var txtDefault = document.getElementById('txtChild');
window.opener.document.form1.txtDefault.value = txtDefault.value;
window.close();
}
default.aspx
function OpenPopup(parentID)
{
var winHeight = 600;
var winWidth = 830;
var url = 'frmChild.aspx?';
options = 'menubar=0,resizable=1,status=0,scrollbars=1,height=' + winHeight + ',width= ' + winWidth +
',left=' + ((screen.width-winWidth)/2) + ',top=' + ((screen.height-winHeight)/2);
window.open( url, '', options );
}
This is working fine and returning me the desired value. which I entered in the child(popup) window.
but, when I am using
window.opener.document.form1.txtDefault.value = txtDefault.value;
in my other application the above is not working. I am very much confussed, what might be wrong, any solution please....
Ram
|
|
|
|
|
Hi all,
I need to know how to authenticate a user before sending a mail using a
C# application. The authentication should be done after sending mail order is initiated. or in other case if possible i need to know how to get the user name and password from the session that the user is signed in to.
The source code i use is this:
private void sendMailButton_Click(object sender, EventArgs e)
{
try
{
MailMessage mailMessage = new
MailMessage(toTextBox.Text, fromTextBox.Text, subjectTextBox.Text,
bodyTextBox.Text);
SmtpClient obj = new SmtpClient(SMTPTextBox.Text);
obj.Send(mailMessage);
MessageBox.Show("Message Sent");
}
catch (Exception ex)
{
MessageBox.Show("message not sent");
}
}
I need to add the authentication part. This is working but with no
authentication for the user or the mail sender address. I am using a
local SMTP server.
Thanks,
Jamil abou khalil
|
|
|
|
|
For sending a mail with authentication..you could try:
try
{
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.To.Add(toTextBox.Text);
message.Subject = subjectTextBox.Text;
message.From = new System.Net.Mail.MailAddress(fromTextBox.Text);
message.Body = bodyTextBox.Text;
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(SMTPTextBox.Text);
smtp.Credentials = new System.Net.NetworkCredential("username", "password");
smtp.Send(message);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
Replace the "username" and "password" with the actual username and password.
Hope that helps,
Ashish
Time flies like an arrow;
Fruit flies like a banana.
Ashish Derhgawen - http://ashishrd.blogspot.com
|
|
|
|
|
HI,
Thanks for your reply but the funny thing is that i posted this article in more than one discussion board and all the replys and answers that i got were the same as your answer. The funny in that is that it never worked. Even if i put the user name and password of the sender and put another sender name it never worked. It is sending the mail all the time.
If there is any other way please do reply and tell me how to.
Thnaks in advance,
Jamil Abou Khalil
|
|
|
|
|
I did a quick google search..I couldn't find any other way..but perhaps you'd find something at: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=717&SiteID=1
I'm still searching for other methods...I'll let you know if I find any.
- Ashish
Time flies like an arrow;
Fruit flies like a banana.
Ashish Derhgawen - http://ashishrd.blogspot.com
|
|
|
|
|
Hi,
I'd like to know how I could launch an URL (preferably in the default browser) with a specific referer, by clicking a a button (or any control really). I've seen various tutorials about making your own web browser, where they show you how this can be done (through the navigate method of the WebBrowser control I believe) but I haven't come across any tutorial that shows how one could achieve that by opening a process (IE, Firefox, etc).
Any help, would be greatly appreciated. Thank you.
|
|
|
|