I am a beginner to web application development. I have the code of a windows application. Same functionality i have to convert into a web application. I have a text box control. I am loading some text to that text box. I want to find the current cursor position, line number and column number. The code for the windows application is below:
private void Form1_Load(object sender, EventArgs e)
{
textBox1.Text = @"This is a demo for text box control
I am trying to find the cursor position ,
line no and column no
of the cursor.";
}
private void textBox1_Click(object sender, EventArgs e)
{
textBox1.SelectionStart++;
label2.Text = textBox1.SelectionStart.ToString();
int i = textBox1.GetLineFromCharIndex(textBox1.SelectionStart);
label3.Text = i.ToString();
int j =textBox1.SelectionStart - textBox1. GetFirstCharIndexFromLine(i);
label4.Text = j.ToString();
}
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if ((e.KeyCode == Keys.Up) || (e.KeyCode == Keys.Right) ||
(e.KeyCode == Keys.Left) || (e.KeyCode == Keys.Down))
{
textBox1.SelectionStart++;
label2.Text = textBox1.SelectionStart.ToString();
int i = textBox1.GetLineFromCharIndex(textBox1.SelectionStart);
label3.Text = i.ToString();
int j = textBox1.SelectionStart -
textBox1.GetFirstCharIndexFromLine(i);
label4.Text = j.ToString();
}
}