I have a javascript that gets the value of the cursor position and it works well. Am assigning that value to asp.net label's innerHtml property. When there s a treeview_selectednodechange event happening i want to access this innerHtml property in my program. How can this be achieved?
this is the javascript 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;
}
And the place where i want 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();
please help.
Thank You