I have a web app in which I want to be able to highlight a word or two in a multi-line textbox, out of several paragraphs of text, and have a button click method manipulate the selected text.
I want to be able to store the selected text in a variable but I haven't been able to find a way to get highlighted text in System.Web.
I know that System.Windows textboxes have the SelectedText property which would be perfect, but unfortunately I don't know how to use anything but the asp.net framework with html pages and c# code behind.
Basically what I am after is an equivalent of TextBox.SelectedText that I can use in a web app, or an alternate route which will accomplish the same result.
The user will be writing the content into the textbox so suggested different controls need to be editable.
I have tried incorporating Javascript into my C# code but it proved too complicated for me, and I don't know how to create a solely javascript web app.
Thank you for your answers so far
Related
I am coding a Windows Forms Application in C#, and one of the requirements is to display some html code in a control, with the correct colors that correspond to the relevant tags.
E.g. When right clicking on a webpage in Google Chrome, then selecting View Page Source, a form is shown with all the html, correctly formatted, with tag colors and each line of code's line number.
Is there a free, reliable control that can do this? Is there an inbuilt Microsoft control that does this?
As I am new to this area of coding, can someone please provide me with some useful names, and some resource links if possible? I am not sure of the correct name for a control that does this, and as such, my Google searches have not come up with what I am looking for.
Also, the control needs to be trustworthy.
Thanks
You can try ScintillaNET control. It's open source and has HTML syntax highlighting as well as many other features.
I tired to make a auto test program which can auto fill/click another webpage based application.
Want my software can eumerate the manually action, ex. click the items, fill the text box...
Now, I can load the page in C# WPF's webbrowser, but didn't know how to auto fill the javascript popup window. we cann't get the elements through funcs like GetElementId(); becasue the page seems written by javascripts.
I'm really a newer on C# and Web.Welcome everyone give comments. Many thanks!
This is the webpage I want to test:
This is the source html I got via IE->View->Source:
Does anyone know how I would show code in a textbox in c#? I am importing the code from a spreadsheet into sql server. Then I need to pull the code out of sql server and store it in a textbox but the spacing is off when I display it and it is hard to read.
Is there any controls or functions that help with this?
Any help is much appreciated.
Edit* This is for a windows form application.
For a Windows Form application if you really need some formatting you should use a RichTextBox
With the RichTextBox control, the user can enter and edit text. The
control also provides more advanced formatting features than the
standard TextBox control. Text can be assigned directly to the
control, or can be loaded from a rich text format (RTF) or plain text
file. The text within the control can be assigned character and
paragraph formatting.
Is this for a web application or a Windows application? There are plugins that do just that for web-based apps.
For instance, I use SyntaxHighlighter by Alex Gorbatchev. It uses javascript so it's not specific to C# or any other language. You can configure it to color different languages e.g., in your case, SQL.
I'm stuck trying to find a solution for my requirement.I know this is possible in windows application but no idea about web application.So Can anyone tell me how to drag and drop to a text box in asp.net web application ?
What i need in my web application is, I have a list box and i want user select single or multiple items and drag it from this list box and drop those items to a text box in Asp.net.so how can i do it in asp.net.
Thanks in advance.
UPDATE
According to this StackOverflow article, it is not possible to do it with the traditional html <select> (ASP.NET ListBox generates a <select> box).
However, you can do similar functionality with <ul><li>, radio buttons.
See this stackoverflow question for reference on to do it using <ul><li> items.
ORIGINAL
You can use a javascript library called jQuery (and more specifically to the jQueryUI library) to add this functionality to your ASP.NET pages.
Link to jQueryUI
Link to jQuery Droppable
Link to jQuery Draggable
Here is another stackoverflow question about drag and drop with a textbox. You will have to do some work on your own to get the exact functionality you need, but I'm sure you can find many examples online.
How can I put a link in a C# TextBox? I have tried to put HTML tags in the box but instead of showing a link it shows the entire HTML tag. Can this be done with a TextBox?
Use the RichTextBox, no need to build your own, it cames with VS
I would try using an editable div and making it look like a text box. This would allow you to get user input and use links.
To make this easier, try JEditable.
If that is in windows forms and you really can't use the richtextbox, you can create a control with a linklabel inside of textbox.
http://www.codeproject.com/KB/miscctrl/LinkTextBox.aspx
I would think about this a little bit. If you allow executable code in an editable control, the user, the user can execute ANY code. This is generally a bad idea.
The behavior of the C# control is intentional to prevent the exact behavior that you are trying to create. A little creativity (such as parsing out links from the text box and creating a list of links next or below the text box) will provide a much safer application.
To my knowledge not with the standard textbox. You'd have to create your own. One option it the Telerik controls, they're a little pricey for individual development, but very robust and configurable.
For windows application, we can use a webbrowser control. However, for web applications Freetextbox will do the job.This is freely available dll.