gi11ies
Programmer
- Mar 26, 2002
- 52
Hi
I posted this in the ASP.NET forum, but was told I'd probably get a better answer here to my problem.
Im trying to make a very basic text editor, that has image buttons for formatting the text. Just now I have if so if you want bold text ... you press the relevant image button and [[]b] goes into the textbox and when you finish the bold text you click it again [[]/b] goes into the text box.
I use this code.
I do replaces when the page is opened, ie [[]b] is <b> and [[]/b] is </b>.
What I want to do is use the cursor to highlight text in the textbox and press the bold image button and it will automatically make that text bold, by doing a replace in the textbox of the selected text putting in [[]b] and [[]/b]
for example
In the textbox
The dog ran after the ball.
If I selected 'dog ran after' so its highlighted, and then pressed the bold image button I created, it replaces the text to.
The [[]b]dog ran after[[]/b] the ball.
Does anyone have any tips on how to do this?
Gillies
I posted this in the ASP.NET forum, but was told I'd probably get a better answer here to my problem.
Im trying to make a very basic text editor, that has image buttons for formatting the text. Just now I have if so if you want bold text ... you press the relevant image button and [[]b] goes into the textbox and when you finish the bold text you click it again [[]/b] goes into the text box.
I use this code.
Code:
Sub btnBold_Click (Sender as Object, e as ImageClickEventArgs)
If Session("boldText") = "boldOff" then
Dim textForBold As String = txtContent.text
Dim textBoldStart As String = textForBold + "[[]b]"
txtContent.text = textBoldStart
lblStatus.Text = "Text Entry is Bold. (click on Bold Text button again to end Bold Text)"
Session("boldText") = "boldOn"
Else
Dim textForBold As String = txtContent.text
Dim textBoldEnd As String = textForBold + "[[]/b]"
txtContent.text = textBoldEnd
lblStatus.Text = "Text Entry is Normal."
Session("boldText") = "boldOff"
End If
End Sub
I do replaces when the page is opened, ie [[]b] is <b> and [[]/b] is </b>.
What I want to do is use the cursor to highlight text in the textbox and press the bold image button and it will automatically make that text bold, by doing a replace in the textbox of the selected text putting in [[]b] and [[]/b]
for example
In the textbox
The dog ran after the ball.
If I selected 'dog ran after' so its highlighted, and then pressed the bold image button I created, it replaces the text to.
The [[]b]dog ran after[[]/b] the ball.
Does anyone have any tips on how to do this?
Gillies