Dynamically add control using CMS

  • Thread starter Thread starter anthonykallay
  • Start date Start date
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
 
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
 
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
 
Back
Top