function ShowSelection()
{
var textComponent = document.getElementById('TextArea1');
var selectedText;
if (document.selection != undefined) {
textComponent.focus();
var sel = document.selection.createRange();
selectedText = sel.text;
}
else if (textComponent.selectionStart != undefined) {
var startPos = textComponent.selectionStart;
var endPos = textComponent.selectionEnd;
selectedText = textComponent.value.substring(startPos,endPos)
}
alert("You selected: " + selectedText)
}
</script>
<asp:TextBox id="TextArea1" TextMode="MultiLine" runat="server">/asp:TextBox>
<a href="#" onclick=alert(ShowSelection());>Click here to display the selected text</a>
Here I am trying to display the selected text by user. I need to display the text which is selected by user.But unfortunately event is not triggering.. Any wrong in this code. Please give me solution..