我有一个获取光标位置值的 javascript,它运行良好。我将该值分配给 asp.net 标签的 innerHtml 属性。当发生 treeview_selectednodechange 事件时,我想在我的程序中访问这个 innerHtml 属性。如何做到这一点?
这是正在使用的javascript:-
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;
}
我想访问它的地方是:-
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();
请帮忙。
谢谢你