I was wondering if this is at all possible, I want to check whether a user has selected text inside a textbox control, just like this solution (but this is just for html input controls and not asp.net server controls)
Asked
Active
Viewed 1,156 times
1
-
1Don't be surprised to much but behind the scene almost all asp.net controls rendering to html controls. So you absolutely free to use solution you referring. – Yuriy Rozhovetskiy Aug 11 '12 at 12:15
2 Answers
2
You need nothing to change
for server control except the syntax
as far as that example is concerned.
<asp:TextBox id="txt1" runat="server" value="Selected?"><asp:TextBox>
<asp:Button id="btnSubmit" runat="server" OnClientClick="alert(isTextSelected();" ></asp:Button>
function isTextSelected() {
input = document.getElementById('<%= test.ClientID %>'))
if (typeof input.selectionStart == "number") {
return input.selectionStart == 0 && input.selectionEnd == input.value.length;
} else if (typeof document.selection != "undefined") {
input.focus();
return document.selection.createRange().text == input.value;
}
}

Adil
- 146,340
- 25
- 209
- 204
0
You can simply achieve this by using
$('select, input').click(function(){
$(this).removeClass('disabled');
});

Josh Bedo
- 3,410
- 3
- 21
- 33