Make a Textbox recognize a url or external link - c#

I would like to know how can i make that a textbox or a richtextbox recognizes a url within a text in windows phone
My textbox is bonded so i don't know what the text will be.
Is there a way to make the textbox recognize the url?
Thank you !

You could try implementing a converter, which does some type of logic based on whatever it is you're trying to accomplish (your question seems a little vague in this sense)
You should look into ValueConverters => http://wpftutorial.net/ValueConverters.html

Related

Using XAML only to prevent characters from being entered in a TextBox

I know how to accomplish this with some code behind my XAML but I am wondering if it is possible to restrict what characters are entered in a textbox using pure XAML with no C#?
I have tried to research this but have found nothing, So I am assuming its not possible so just checking here.
Could write a markup extension returning a filter in the text change event. It's fairly messy and still requires the code for the extension, but you could then provide the limited characters in XAML.
Alternatively an attached property could provide the same functionality and is probably a bit cleaner in this case.
Lastly you could subclass the TextBox control and make the logic and internal part of the control that can be configured with a dependency property.
You can inherit the textbox "Behavior<TextBox>" and add your logic in OnPreviewTextInput event to check for validation.

Best method or control to display text from a file in an asp.net webpage

This may be a totally newbie question, but here it goes. I have a asp.net web page that I need to display text from a .txt file. I am trying to figure what would be the best control to do this with or the best method. I looked at using an iframe, but this does a very poor job of displaying the text from the file (for instance no word wrap for an iframe). I don't really expect anyone to solve this for me completely, but if you have any suggestions or know of any links to tutorials or explanations where someone has done this, I would be very greatful.
Thanks
You can for example add a Literal control, assign File.ReadAllLines("yourfile.txt") to the Text property and replace \r\n with <br />.
You should just read the text-file in code (using a streamreader for example). Once you have that text, just output it to your web page.
If you're using web forms you could place a label and then set the text of that label.
If you're using MVC you could put it in the ViewBag and then in your view output the value from the ViewBag (or use a custom viewmodel)
You could use a Literal or Label control. Make sure that the control that you use encodes the text in order to avoid XSS vulnerabilities (or encode the text manually if necessary).
It might as well be necessary to substitute line endings with <br/> tags.

XML text Editor - Text Box

I would like to design one xml text editor which is based on normal text-box which implements all XML characteristics(i.e., it should implement intelligence to differentiate the text colors by node_name,attribute_name,attribute_value and it should check proper closing the tag).
Can any one give me the idea how I could process the each and every character entered by the user(normally we can call the TextBox1_TextChanged event after fully entered the text in text-box but I need to call this event each and every character entry)? I am good in C#, so that I have decided to transform the control to coding page because I already did one editor using console application which read the input character from the user and change the text color.
I might be wrong to approach this problem like this way so, give your suggestions, valuable reference links and ideas to accomplish this editor.
If you know any plugins to do this task please inform me
Thanks in Advance.
Regards,
--SJ
Use a Rich Text Box and handle the KeyDown event for character processing.
Rich Text Box will allow you to do syntax highlighting, text formatting, etc.
I would also validate entered xml for correctness and possibly highlight incorrect syntax to the user if validation fails.
All this is going to required effort, i am not aware of any QUICK solution. But using the basics i've suggested here, you could achieve what you require if you put in the effort.
The EditArea appears to have the features (and more) that you are looking for.
You could also check the list of Javascript base source code editors

Prevent submit empty textbox in Windows 8 Metro Application

is there any control like RequiredFeild control (asp.net) in windows 8 metro? I have a simple form with several text boxes and I just want to make sure to prevent submit it when a textbox is empty. I know it can be easy in code but I'm eager to know are there any alternative ways?
You might want to use WinRT XAML Toolkit:
TextBoxValidationExtensions - extensions that allow to specify the
Format of the requested Text input as well as brushes to use to
highlight a TextBox with valid or invalid Text.
I'm assuming you actually want to validate the input.
this is another solution that I found.
Here
Why you don't use String.IsNullOrEmpty() ?

TextBox Label Control

I am not worried about whether this is in Winforms or WPF.
Is there ANY way at all that I could develop my own user control like the one found in Microsoft Paint, below:
If you can't see the pic above, it's here: http://img232.imageshack.us/i/txtboxlblctrl.png/
Is there anyway at all I can do something like this in C#?
Thank you
Sure you can. By developing your own Usercontrol you can do nearly anything.
I think the easiest way would be to use a WPF TextBox and alternate it with a template.
This [http://img199.imageshack.us/i/textboxu.png/] is what you get by simply using [http://img163.imageshack.us/i/stipe.png/] as BorderBrush

Categories