Dynamically add control using CMS

A

anthonykallay

Hi there,

I have a built a CMS system that allows users to do all the usual
functions (add/edit pages), what i would like is for the user to be
able to be able to insert a pre defined control into the page text
using the editor that loads into a Literal control..

For example they may write out apage as below

<p>This is para1</p>

<p>This is para 2</p>

<% Control code is entered here %>

<p>Continue with text on the page</p>

Is this possble in .Net and if not how would one go about inserting
controls into the body of dynamically created text???

Cheers
Anthony
 
G

Guest

Hi there,

I have a built a CMS system that allows users to do all the usual
functions (add/edit pages), what i would like is for the user to be
able to be able to insert a pre defined control into the page text
using the editor that loads into a Literal control..

For example they may write out apage as below

<p>This is para1</p>

<p>This is para 2</p>

<% Control code is entered here %>

<p>Continue with text on the page</p>

Is this possble in .Net and if not how would one go about inserting
controls into the body of dynamically created text???

Cheers
Anthony

I think you can try to use ParseControl Method

Private Sub Page_Load(...)

If Not Page.IsPostBack Then
Dim txt = ...
Dim ctrl As Control = Page.ParseControl(txt)
Me.Controls.Add(ctrl)
End If

End Sub

See examples on http://msdn.microsoft.com/en-us/library/kz3ffe28.aspx
 
A

anthonykallay

Hi Alexay,

Thanks for you response, like i mentioned the txt string from the
database doesnt contain just a control it also contains other html for
the page, would i need to grab the control code from the string and
try and parse just that bit??

Cheers
Anthony
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,067
Latest member
HunterTere

Latest Threads

Top