[Solved] Entering value to database after pressing enter from a textbox [closed]

Use for this KeyDown event private void YourTextBox_KeyDown(object sender, KeyEventArgs e) { String connection= “Data Source=YourServer;Initial Catalog=YourDatabase;user=User;password=YourPassword;Integrated Security=True;”; if (e.KeyCode == Keys.Enter) { string insertCmdText = “INSERT INTO table(column1)values(@valueForColumn1)”; SqlCommand sqlCom = new SqlCommand(insertCmdText,connection); sqlCom.Paramaters.AddWithValue(“@valueForColumn1”,YourTextBox.Text); connection.Open(); sqlCom.ExecuteNonQuery(); connection.Close(); } } But consider that saving into Database after KeyPress event is not a right way to … Read more

[Solved] c# searching on C:\Users\John\Desktop using the text on text.box as search key? [closed]

Below should work. It enumerates that path. Be sure to have a multiline textbox called txtOutput, and a txtSearch named control. You can put this in a button click or where ever. txtOutput.Text = “”; foreach(string file in Directory.GetFiles(“c:\\path”)) if(Path.GetFileName(file).Contains(txtSearch.Text)) txtOutput.Text += txtOutput.Text + file + “, “; 2 solved c# searching on C:\Users\John\Desktop using … Read more

[Solved] How to create a .txt file using c#? [closed]

Try this, if you want to save username password in the same file string fileName = textBox1.Text + “.txt”; System.IO.File.WriteAllText(@”C:\\Users\\User\\Documents\\1ClickData\\ID\\” + fileName, “Username=”+textBox1.Text+” Password=”+textBox2.Text); or if you want to save username and password in separate file //for username string fileName1 = textBox1.Text + “.txt”; System.IO.File.WriteAllText(@”C:\\Users\\User\\Documents\\1ClickData\\ID\\” + fileName1, textBox1.Text); //for password string fileName2 = textBox2.Text + … Read more

[Solved] TextBox not containing “\r\n” strings

As I said in the comment, with Multiline=True and WordWrap=True, your textbox will display a long line as multilines (Wrapped)… but actually it is one single line, and that’s why your Lines.Length=1, try type in some line break yourself, and test it again. Or you can set WordWrap=False, and you will see there is only … Read more

[Solved] ASP.NET: How to create a search function just using a textbox? [closed]

Since you didn’t provide any code here and asked for the directions, so here you go. Lets assume your TextBox name is ‘textBox1‘ and there is some button beside it. On the click event of that button you should be querying your database for the customer names that matches the text inside your ‘textBox1‘. The … Read more

[Solved] How to make a text box change depending on a dropdown menu

This code shows how you can accomplish what you seek. As others have mentioned, it’s not exactly the most secure / efficient way to do this, especially if you’re dealing with real money, but all you have to do to get this to work is add jquery to your html file with <script src=”http://code.jquery.com/jquery-latest.min.js”></script> $(‘#myPRODUVTS’).on(‘change’, … Read more

[Solved] Extract numbers out of a textbox [closed]

This is possible. You’ll actually need to convert 000001111100000111111100000011 or 000111000111000111000111000111 which will be treated as string to a byte array byte[]. To do this, we’ll use Convert.ToByte(object value, IFormatProvider provider) string input = “BINARY GOES HERE”; int numOfBytes = input.Length / 8; //Get binary length and divide it by 8 byte[] bytes = new … Read more

[Solved] Comparing two textboxes with datetime value in jquery

Something like this ? function onChange(sender, txt, departed) { var txtArrival = $(“#txtArrivalDate”); var txtArrivalDate = $(txtArrival).val(); //Value from arrival var txtDate = $(txt).val(); //Value from departed var departureDate = new Date(txtDate); //Converting string to date var arrivalDate = new Date(txtArrivalDate); //Converting string to date if (departureDate.getTime() < arrivalDate.getTime()) { txt.val(txtArrivalDate); //Does not work, value … Read more