[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.webcontrols

Dynamic controls using Parsecontrol methos

Bhagwati

3/2/2004 7:22:00 AM

Hello everybody,
I am using xml and xslt to generate dynamic asp
server controls on the page. What I do is I store the control type and their
attributes in the database. And then using xml, i retrieve those controls
and then using xslt transform method , i get a stream object. I convert it
into string and pass it to the parsecontrol method in the page_init method.
All works fine, but the problem is that the server side events are not
handled. I somehow need to wire the events to the control, I dont how to go
abt it ? If u have come up across this or u have any ideas ,plz do reply.

Regards,
Bhagwati

The code for the page_init is

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init

Dim surveyDoc As XPathDocument

Dim transform As XslTransform

Dim survey As New PlaceHolder()

Dim sw As StringWriter

surveyDoc = New XPathDocument(Server.MapPath("xmlfile1.xml"))

transform = New XslTransform()

transform.Load(Server.MapPath("xsltfile1.xslt"))

sw = New StringWriter()

transform.Transform(surveyDoc, Nothing, sw)

Dim result As String

result = sw.ToString()

result = result.Replace("xmlns:asp=""remove""", " ")

Dim ctrl As Control

ctrl = Page.ParseControl(result)

Me.PlaceHolder1.Controls.Add(ctrl)

InitializeComponent()

End Sub



1 Answer

Teemu Keiski

3/2/2004 8:32:00 AM

0

Hi,

see this:
Dynamically Adding Web Controls and adding event delegates
http://weblogs.asp.net/kaevans/archive/2003/02/22...

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist


"Bhagwati" <bhagwatipm@hyd.solutionsoftware.com> wrote in message
news:ed7cTfCAEHA.808@TK2MSFTNGP12.phx.gbl...
> Hello everybody,
> I am using xml and xslt to generate dynamic asp
> server controls on the page. What I do is I store the control type and
their
> attributes in the database. And then using xml, i retrieve those controls
> and then using xslt transform method , i get a stream object. I convert it
> into string and pass it to the parsecontrol method in the page_init
method.
> All works fine, but the problem is that the server side events are not
> handled. I somehow need to wire the events to the control, I dont how to
go
> abt it ? If u have come up across this or u have any ideas ,plz do reply.
>
> Regards,
> Bhagwati
>
> The code for the page_init is
>
> Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Init
>
> Dim surveyDoc As XPathDocument
>
> Dim transform As XslTransform
>
> Dim survey As New PlaceHolder()
>
> Dim sw As StringWriter
>
> surveyDoc = New XPathDocument(Server.MapPath("xmlfile1.xml"))
>
> transform = New XslTransform()
>
> transform.Load(Server.MapPath("xsltfile1.xslt"))
>
> sw = New StringWriter()
>
> transform.Transform(surveyDoc, Nothing, sw)
>
> Dim result As String
>
> result = sw.ToString()
>
> result = result.Replace("xmlns:asp=""remove""", " ")
>
> Dim ctrl As Control
>
> ctrl = Page.ParseControl(result)
>
> Me.PlaceHolder1.Controls.Add(ctrl)
>
> InitializeComponent()
>
> End Sub
>
>
>