Over come placeholder text with innerText - c#

What I want to do is to fill it with text programatically.
webBrowser1.Document.GetElementById("textBox").InnerText = "foo";
This code works but some websites have a placeholder text. This code will not allow me to fill this as value but instead it as a placeholder text.
Strangely in some text box, it will be paste as value when there are a placeholder text. But some text box it wont.
Another scenario is that when it is innerText is placed as a placeholder text, all I have to do is click on that text box and write something next to it. This will act as a text box values.
Is there another way around this?

You need to set the value attribute of the <input id='textBox'> elment not the innertext.
webBrowser1.Document.GetElementById("textBox").SetAttribute("value", "text text text");

Related

C# How can I get masked password from textbox?

I've set property of my textbox1 with PasswordChar = '*' and textbox display correct text that is ****.
But when I want to use that masked text (****) by set label1.text = textbox1.text, why label1.text show plain password text which not masked and how can I get masked text from my textbox1?
To use a TextBox for passwords, just set the PasswordChar value to anything other than NULL and it will automatically hide the characters typed.
This is purely for display purposes and so if you copy the text elsewhere it won't be hidden.
Then you should customize the label to display text as masked and you should extended PasswordChar property to label.

Multiline Textbox that receives the lines on top

I have a multiline textbox that receives values from a different class, and I want that every line is added on top instead of the bottom, how can I do that?
Use String.Insert():
textBox.Text = textBox.Text.Insert(0, string.Format("{0}\r\n", "Your text content here"));

Bootstrap Wysiwyg Editor: Saved Data in HTML to Database, trying to send the HTML back to the editor in richtextbox format

So, I have the rich text box editor from Bootstrap-Wysiwyg.
If the textbox contains:
This is a bold statement.
Then my DB will save the text as:
(using a hidden tab where I insert the editor.html())
<b>This is a bold statement.<b>
If I save the file again, the RTF will convert it to:
<b>This is a bold statement.<b>
When I put the this text back into the editor using a Model.Value, it does not convert it to rich text but instead keeps the text as though it were a string and states it exactly as it is saved in the DB.
How can I convert the text in my model to show up in the rich text editors format?
I've been searching the net quite a bit, and most functionality refers to files. This is a new subject to me, so any insight is appreciated on how to fix this. (Editing text without formatting is obnoxious!) Thanks in advance!
Just in case someone else gets stuck, I was able to resolve this issue by doing the following:
I created a hidden div (which I populate first with my Model):
<textarea style="display: none;" id="editorCopy" name="body">#Model.Body</textarea>
and left my editor div empty:
<div id="editor" contenteditable="true">
</div>
and in my JQuery:
I set my editors text to my hidden divs value, and on submit, I replace the hidden div with my editor text:
$('#editor').html($('#editorCopy').val());
$('#postSubmit').click(function () {
$('#editorCopy').val($('#editor').html());
});
This allowed my rich text to show on edit. There might be a better solution, but at least this works! :]

Get selected HTML from ComponentOne RichTextBox?

I have a C# Windows Phone 8 app with a ComponentOne RichTextBox contorl. How do I get the selected HTML that corresponds to the current value of a RichTextBox control's SelectedText property? (the current selection)
For example, suppose I have the current HTML in the RichTextbox:
<p>Some text</p><p><i>italicized text</i></p><p>Text not selected</p>
And the user selects "Some text" and "italicized text" by tapping. The SelectedText property will be "some text italicized text" and what I want to back as the selected HTML is:
<p>Some text</p><p><i>italicized text</i></p>
Is there a way to do this without doing some really messy operation walking the HTML while accumulating tags until the accumulated text matches the SelectedText property?

Remove text box of MS word document

I have few MS word documents which contains text in text boxes. I want to remove those text boxes but keep the data as it. How can i do it ?
I think you can get hold of the text from inside the textboxes using something like ActiveDocument.Shapes(1).TextFrame.TextRange.Text and then you could delete it by doing something like ActiveDocument.Shapes(1).Delete, and after that you'd have to put the text you retrieved from the text box in the relevant part of the document.

Categories

Resources