Click here to Skip to main content
15,890,282 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Friends.
can anyone tell me how to get the Selected text form any

Browsers ( IE, Fire Fox etc ) in c#. Please help me.

Thanks
Posted

It is not possible to get the Selected value in the CodeBehind file at Server. But, it is possible to get the selected text (By Mouse or KeyBoard) by JavaScript. If you need to get the selected value in CodeBehind file, you can set the selected text into a hidden field (Using Javascript) and this will let you get the value when the form is submitted (Or, Posted back) to Server.

You will get a few JQuery plugin for getting the Selected text if you Google. This http://perplexed.co.uk/1020_text_selector_jquery_plugin.htm[^] might help you.
 
Share this answer
 
v2
Comments
thatraja 23-Dec-10 5:44am    
"Are you talking about Asp.net Web application?"
surely dude because he mentioned browser in his question. He might been forgot to mention that in question Tag.
Al-Farooque Shubho 23-Dec-10 5:45am    
Oh..yes. Didn't notice that :) Thanks
No , I want to do it in c# only.
 
Share this answer
 
Comments
Al-Farooque Shubho 23-Dec-10 5:47am    
Sorry dude, not possible. Browser simply doesn't send any necessary information (Regarding the selected text) with the Http Request. You need to get that using JavaScript only.
thatraja 23-Dec-10 6:22am    
@attiq_khan: why man? he gave you good answer. any particular reason for you want to do using c# instead of javascript?
attiq_khan 23-Dec-10 6:24am    
i am going to make a application in c# that Capture a Selected Text from any Website.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900