I have a JavaScript function that successfully retrieves the cursor position value. I am assigning this value to an ASP.NET label's innerHTML property. How can I access this innerHTML property when a treeview_selectednodechange event occurs in my program?
This is the JavaScript function I am using:
function ShowSelection() {
var txt1 = document.getElementById("MainContent_txtQuery");
var currentRange = document.selection.createRange();
var workRange = currentRange.duplicate();
txt1.select();
var allRange = document.selection.createRange();
var len = 0;
while (workRange.compareEndPoints("StartToStart", allRange) > 0)
{
workRange.moveStart("character", -1);
len++;
}
currentRange.select();
document.getElementById("MainContent_lblPos").innerHTML = len;
}
The section where I need to access it is:
string[] selectedNode = treeViewTables.SelectedNode.Text.Split('<', '>');
string pos = lblPos.Text;
if (selectedNode[2].Equals("Table(s)") || selectedNode[2].Equals("Parameter(s)"))
{
return;
}
string parentNode = treeViewTables.SelectedNode.Parent.Text;
if (parentNode.Contains("Table(s)"))
{
txtQuery.Text = txtQuery.Text + " " + selectedNode[2];
txtQuery.Text = RemoveSpaces(txtQuery.Text);
}
else if (parentNode.Contains("Parameter"))
{
//if (txtQuery.Text != "")
if (lblPos.Text == string.Empty)
{
if (txtQuery.Text.Length == 0)
{
txtQuery.Text = selectedNode[2];
}
else if (txtQuery.Text[txtQuery.Text.Length - 1] != ',')
{
txtQuery.Text = txtQuery.Text + " " + "'" + selectedNode[2] + "'";
txtQuery.Text = RemoveSpaces(txtQuery.Text);
}
else
{
txtQuery.Text = txtQuery.Text + " " + selectedNode[2];
txtQuery.Text = RemoveSpaces(txtQuery.Text);
}
}
}
else
{
txtQuery.Text = txtQuery.Text + " " + selectedNode[2] + ",";
txtQuery.Text = RemoveSpaces(txtQuery.Text);
}
TreeNode nodeSelected = treeViewTables.Nodes[0];
nodeSelected.Select();
Any assistance would be highly appreciated.
Thank You