Home All Groups Group Topic Archive Search About
Author
16 Oct 2006 11:40 PM
Duncan Dimech
Dear All
I am writing a tool which requires to have controls added to it dynamically.
To make the task more complex, the addition of the control cannot happen
anywhere but it has to be instead of a token

example

<p> this is a test  <textbox /> and a text box should be entered </P>

the tool should render the message and instead of  <textbox /> it should
show an ASP.Net textbox control

Please note that position cannot be predetermined


Thanks for the support, it will be appreciated
Duncan

Author
17 Oct 2006 12:32 AM
Cowboy (Gregory A. Beamer)
Are you allowed to parse and then display? If so, you can set up the page
with a pass and then redirect the user to the new page If this is not a
possibility, you will have to set up a handler to create the parse and
display bits. The easiest might be inheriting from the page class and
creating the scripting engine to display from a raw parse. Either way, it is
going to be a pain.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com

*************************************************
Think outside of the box!
*************************************************
Show quoteHide quote
"Duncan Dimech" <dun***@exorgroup.com> wrote in message
news:O7NUTyX8GHA.3820@TK2MSFTNGP02.phx.gbl...
> Dear All
> I am writing a tool which requires to have controls added to it
> dynamically. To make the task more complex, the addition of the control
> cannot happen anywhere but it has to be instead of a token
>
> example
>
> <p> this is a test  <textbox /> and a text box should be entered </P>
>
> the tool should render the message and instead of  <textbox /> it should
> show an ASP.Net textbox control
>
> Please note that position cannot be predetermined
>
>
> Thanks for the support, it will be appreciated
> Duncan
>
Author
17 Oct 2006 12:38 AM
Duncan Dimech
I am first parsing and then diplaying the info

Can you please elaborate on your solution

Duncan

Show quoteHide quote
"Cowboy (Gregory A. Beamer)" <NoSpamMgbworld@comcast.netNoSpamM> wrote in
message news:%23T6TwOY8GHA.2092@TK2MSFTNGP03.phx.gbl...
> Are you allowed to parse and then display? If so, you can set up the page
> with a pass and then redirect the user to the new page If this is not a
> possibility, you will have to set up a handler to create the parse and
> display bits. The easiest might be inheriting from the page class and
> creating the scripting engine to display from a raw parse. Either way, it
> is going to be a pain.
>
> --
> Gregory A. Beamer
> MVP; MCP: +I, SE, SD, DBA
> http://gregorybeamer.spaces.live.com
>
> *************************************************
> Think outside of the box!
> *************************************************
> "Duncan Dimech" <dun***@exorgroup.com> wrote in message
> news:O7NUTyX8GHA.3820@TK2MSFTNGP02.phx.gbl...
>> Dear All
>> I am writing a tool which requires to have controls added to it
>> dynamically. To make the task more complex, the addition of the control
>> cannot happen anywhere but it has to be instead of a token
>>
>> example
>>
>> <p> this is a test  <textbox /> and a text box should be entered </P>
>>
>> the tool should render the message and instead of  <textbox /> it should
>> show an ASP.Net textbox control
>>
>> Please note that position cannot be predetermined
>>
>>
>> Thanks for the support, it will be appreciated
>> Duncan
>>
>
>
Author
17 Oct 2006 3:51 PM
Michael Hamrah
On postback, pull the string from the textbox.  Use regular expressions
or string.replace to replace the keyword tokens with valid asp.net
syntax.  Then, call the ParseControl() function to render the output.
This will return a new control with all the child elements instantiated
and you can add it to the current page.  If you plan on manipulating or
using the new controls on subsequent postbacks you'll need to add the
parsed control in the init event for them to work properly.


Duncan Dimech wrote:
Show quoteHide quote
> I am first parsing and then diplaying the info
>
> Can you please elaborate on your solution
>
> Duncan
>
> "Cowboy (Gregory A. Beamer)" <NoSpamMgbworld@comcast.netNoSpamM> wrote in
> message news:%23T6TwOY8GHA.2092@TK2MSFTNGP03.phx.gbl...
> > Are you allowed to parse and then display? If so, you can set up the page
> > with a pass and then redirect the user to the new page If this is not a
> > possibility, you will have to set up a handler to create the parse and
> > display bits. The easiest might be inheriting from the page class and
> > creating the scripting engine to display from a raw parse. Either way, it
> > is going to be a pain.
> >
> > --
> > Gregory A. Beamer
> > MVP; MCP: +I, SE, SD, DBA
> > http://gregorybeamer.spaces.live.com
> >
> > *************************************************
> > Think outside of the box!
> > *************************************************
> > "Duncan Dimech" <dun***@exorgroup.com> wrote in message
> > news:O7NUTyX8GHA.3820@TK2MSFTNGP02.phx.gbl...
> >> Dear All
> >> I am writing a tool which requires to have controls added to it
> >> dynamically. To make the task more complex, the addition of the control
> >> cannot happen anywhere but it has to be instead of a token
> >>
> >> example
> >>
> >> <p> this is a test  <textbox /> and a text box should be entered </P>
> >>
> >> the tool should render the message and instead of  <textbox /> it should
> >> show an ASP.Net textbox control
> >>
> >> Please note that position cannot be predetermined
> >>
> >>
> >> Thanks for the support, it will be appreciated
> >> Duncan
> >>
> >
> >
Author
17 Oct 2006 11:40 PM
Duncan Dimech
Thanks to Micheal and Gregory

I have managed to add controls to a page and handle the event of the button
which solves the first part of the problem - second is then quite easy as
one will just need to find the token and split the text in two variables or
array

Code for initial part is shared below in case you are having the same
problem like me

    Protected Sub Page_Init(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Init
        Dim c As Control 'declare control
        c = ParseControl("HelloWorld <br /> ") 'parsecontrol takes text as
well as html
        form1.Controls.Add(c) 'add control to form

        c = ParseControl("<asp:Button ID=""Button1"" runat=""server""
Text=""Button"" />") 'html for button
        form1.Controls.Add(c)

        Dim btn As Button = FindControl("Button1")
        AddHandler btn.Click, AddressOf MyOtherClick  'add event handler for
button

        c = ParseControl("<asp:TextBox ID=""Searchbox""
runat=""server""></asp:TextBox>")
        form1.Controls.Add(c) 'adding a textbox control

        c = ParseControl("<br /> End Here")
        form1.Controls.Add(c) 'adding html

    End Sub

    Private Sub MyOtherClick(ByVal sender As Object, ByVal e As EventArgs)
        Dim tb As TextBox = Me.Page.FindControl("Searchbox")
        MsgBox(tb.Text) 'display contents of text box
    End Sub

Duncan


Show quoteHide quote
"Michael Hamrah" <mham***@gmail.com> wrote in message
news:1161100262.570917.186700@m7g2000cwm.googlegroups.com...
> On postback, pull the string from the textbox.  Use regular expressions
> or string.replace to replace the keyword tokens with valid asp.net
> syntax.  Then, call the ParseControl() function to render the output.
> This will return a new control with all the child elements instantiated
> and you can add it to the current page.  If you plan on manipulating or
> using the new controls on subsequent postbacks you'll need to add the
> parsed control in the init event for them to work properly.
>
>
> Duncan Dimech wrote:
>> I am first parsing and then diplaying the info
>>
>> Can you please elaborate on your solution
>>
>> Duncan
>>
>> "Cowboy (Gregory A. Beamer)" <NoSpamMgbworld@comcast.netNoSpamM> wrote in
>> message news:%23T6TwOY8GHA.2092@TK2MSFTNGP03.phx.gbl...
>> > Are you allowed to parse and then display? If so, you can set up the
>> > page
>> > with a pass and then redirect the user to the new page If this is not a
>> > possibility, you will have to set up a handler to create the parse and
>> > display bits. The easiest might be inheriting from the page class and
>> > creating the scripting engine to display from a raw parse. Either way,
>> > it
>> > is going to be a pain.
>> >
>> > --
>> > Gregory A. Beamer
>> > MVP; MCP: +I, SE, SD, DBA
>> > http://gregorybeamer.spaces.live.com
>> >
>> > *************************************************
>> > Think outside of the box!
>> > *************************************************
>> > "Duncan Dimech" <dun***@exorgroup.com> wrote in message
>> > news:O7NUTyX8GHA.3820@TK2MSFTNGP02.phx.gbl...
>> >> Dear All
>> >> I am writing a tool which requires to have controls added to it
>> >> dynamically. To make the task more complex, the addition of the
>> >> control
>> >> cannot happen anywhere but it has to be instead of a token
>> >>
>> >> example
>> >>
>> >> <p> this is a test  <textbox /> and a text box should be entered </P>
>> >>
>> >> the tool should render the message and instead of  <textbox /> it
>> >> should
>> >> show an ASP.Net textbox control
>> >>
>> >> Please note that position cannot be predetermined
>> >>
>> >>
>> >> Thanks for the support, it will be appreciated
>> >> Duncan
>> >>
>> >
>> >
>