Dynamically adding a control...I think! :)

  • Thread starter Web Team @ Borough of Poole
  • Start date
W

Web Team @ Borough of Poole

Hi All,

I'm in the process of writing a eich text editor web custom control.

The actual text/HTML is displayed/editied in a DIV layer, which I have
created like this:

output.Write("<span class=" & EditDivCSSClass & " id=" & Me.ID & " " &
strContentEditable & " wrap>" & _strText & "</span>")

I drag my control onto the containing page, set the strText property,
which successfully ends up within the DIV. This is fine, until I come
to saving the editied text, which I will need to get back from the
control, then write to a DB/Txt file/XML...etc.

I *think*, that rather than output.writing the DIV layer, I need to
dynamically add a DIV/Layer control, which will then be accessible to
my custom control, which in turn can return a property containing the
string of user editied text.

Can anyone point my in the right direction here? Am I thinking about
this the right way?

Thanks for any help!

Simon.
 
K

Kevin Spencer

Well, for starters, a span is not a div. But as to your question, yes, I
believe that developing a custom Control that uses nested divs (Panels) is
the right way to go. In actual fact, you're probably talking about a whole
set of Controls and classes. An HTML document is not simply a long string of
text, but viewed abstractly, a set of a variety of objects that share the
same document space.

In an ASP.Net rich text editor, you might want to create or inherit Controls
that represent all of the HTML element types. When a user selects a type of
element from a drop-down list box, you could add one of those Controls to
the parent Control. When the user hits ENTER, you could add a new Paragraph
Control to the parent Control. And so on.

You do have your work cut out for you, however. HTML is a pretty complex
animal. Your Controls would have to support nesting, CSS and/or inline
styles, attributes, dragging and dropping, handling keyboard input,
client-side Clipboard support, etc. As Microsoft has already created such
Controls for any HTML element inside of the body of an HTML document, you
would probably want to inherit them and add the functionality for the rich
text editor to them. It would be an excellent idea to sit down and architect
how this app will work in some detail before writing any code.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 
W

Web Team @ Borough of Poole

Hi Kevin,

Thanks for your answer - Although I think you may have missed my
objective here.

Whilst I do have an understanding of the HTML DOM, as far as my app is
concerned, when the user has finished editing, I am simply (!) saving a
string of text (Which happens to be HTML).

My problem is getting this string out of my custom control after the
user finishes editing and hits the 'save' button.

At present, my control (And there fore the containing page) is not
aware of the <span (its just a chunk of HTML written to the page which
happens to have a 'contenteditable' attribute.

What I need, is the SPAN to be a server control, which I can then do
something like this with when the user saves:

strPageData = me.editablespan.text
....Write strPageDate to a DB/txt/XML file.

Hope that makes sense.

Thanks again,
Simon.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top