0

This is my first post, so I hope it finds it's way to the correct forum.

I created a web page with a SQL backend to capture the start time for a production job. There is only one textbox on the page. After the timestamp is saved, the focus is directed back to the textbox so that the next timestamp can be entered. It works fine for the browsers on my PC..I've tested it in IE and Chrome both.

However, the end user will be using a Kindle Fire HD tablet to input data. The form displays properly on Kindle's Silk Browser, but the focus doesn't set on my textbox. I have to use my finger to press inside the textbox in order for the cursor to appear.

I wrote code in both C# and JS to set the focus on my textbox, but neither approach worked on the Silk Browser. Again, it works fine on my PC for IE and Chrome.

I mostly work with SQL and I'm just starting to branch out into .net and C#. If someone could point me in the right direction, I would certainly appreciate it. Thanks!

void btnSave_Click(object sender, EventArgs e) {
cmd = new SqlCommand("UpdateEndTime_sp", con); 
cmd.CommandType = CommandType.StoredProcedure; 
cmd.Parameters.Add("@WorkOrderNum", SqlDbType.Int).Value = tbWorkOrderNum.Text; con.Open(); 
cmd.ExecuteNonQuery(); 
con.Close(); 
tbWorkOrderNum.Text = ""; 
Label1.Visible = true; 
tbWorkOrderNum.Focus(); 

Javascript:

if (document.getElementById("Textbox1").value == "") { 
  document.getElementById("Textbox1").focus(); 
} 
MatthewMartin
  • 32,326
  • 33
  • 105
  • 164
Jay Alfred
  • 21
  • 1
  • 3
  • Can u post C#/JS code u using for focusing? – Yuriy Galanter Jul 28 '14 at 16:48
  • Sure. Here is the C#. protected void btnSave_Click(object sender, EventArgs e) {cmd = new SqlCommand("UpdateEndTime_sp", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@WorkOrderNum", SqlDbType.Int).Value = tbWorkOrderNum.Text; con.Open(); cmd.ExecuteNonQuery(); con.Close(); tbWorkOrderNum.Text = ""; Label1.Visible = true; tbWorkOrderNum.Focus(); – Jay Alfred Jul 28 '14 at 16:57
  • And the Java Script: – Jay Alfred Jul 28 '14 at 17:01
  • 1
    It would be easier if you updated your question text with formatted code, it's really hard to read it in comments. Also it looks like focusing on 2 different textboxes: C# does `tbWorkOrderNum` and JS does `Textbox1`. Which one is correct? – Yuriy Galanter Jul 28 '14 at 17:06
  • document.getElementById("Textbox1") Do a view source and make sure that the element Id is really TextBox1 and not a machine generated, munged Id. This is a common situation for the ServerId to only be used a part of the html element id. – MatthewMartin Jul 28 '14 at 17:10
  • Possible duplicate of [How to focus an input field on Android browser through javascript or jquery](https://stackoverflow.com/questions/8858094/how-to-focus-an-input-field-on-android-browser-through-javascript-or-jquery) – Paul Sweatte Jul 08 '17 at 19:03

0 Answers0