|
-
Apr 30th, 2013, 03:06 AM
#1
Thread Starter
Addicted Member
Hilight text in webbrowser that meets a criteria...
This may or maynot be possible, but thought I would ask the question anyway.
I have a webbrowser control on a form that I am using to allow my users to create custom email templates within my application. I then have a number of button on the form that enters predefined tags within the webbrowser that then I replace with valid data before sending the email. I will give you an example which will probably clarify it better, I have a button that inserts the users name into the webbrowser e.g. it add text [USER_FIRST_NAME] this then allows me to replace [USER_FIRST_NAME] with the actual users first name who sends the email. Therefore making this email templates.
The problem that the user when designing the email templates could click on the [USER_FIRST_NAME] tag text and edit each character. What I would like is when the user clicks in the webbrowser it somehow checks to see if the cursor is within a tag e.g. within the [ and ] and then hilights the whole tag. This would therefore not allow then to edit the content of the tag text.
I hope that makes sense? There are no spaces in my tags, all spaces have _ (underbars)
Thanks in advance
Simon
-
Apr 30th, 2013, 12:09 PM
#2
Member
Re: Hilight text in webbrowser that meets a criteria...
If you are using web elements or whatever to do this, you can use the replace code:
RichTextBox1.Text = RichTextBox1.Text.Replace("[USER_FIRST_NAME]", "DesignLife")
-
Apr 30th, 2013, 12:10 PM
#3
Member
Re: Hilight text in webbrowser that meets a criteria...
Just format it in a rich text box then use GetElementByID to locate the body for the email, then put the text from the RTB into it. You can play with the code to alter it and make it use names and such from a list box.
-
May 1st, 2013, 03:14 AM
#4
Thread Starter
Addicted Member
Re: Hilight text in webbrowser that meets a criteria...
DesignLife,
It was not the replacing the text that I was having an issue with, but hilighting the entire tag in the webbrowser control (same functionality if you double click a word in the webbrowser control is hilights the whole word) e.g. [USER_FIRST_NAME] if the user clicks anywhere inside the square brackets it hilights the whole tag from [ to ]. This will then stop them from editing the tag content to something that is not valid.
-
May 1st, 2013, 10:48 AM
#5
Re: Hilight text in webbrowser that meets a criteria...
This will then stop them from editing the tag content to something that is not valid.
Er ... how? Highlighting doesn't stop anybody doing anything. Meanwhile it's far from clear exactly what you are wanting here. Are you using the webbrowser as an editor directly (an arcane process filled with delightful traps)? If the functionality is the same as the double click why don't you just turn a click into a double click?
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|