469,317 Members | 1,982 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,317 developers. It's quick & easy.

Adding Web Control

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

<pthis 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
Oct 16 '06 #1
4 1497
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" <du****@exorgroup.comwrote in message
news:O7**************@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

<pthis 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

Oct 17 '06 #2
I am first parsing and then diplaying the info

Can you please elaborate on your solution

Duncan

"Cowboy (Gregory A. Beamer)" <No************@comcast.netNoSpamMwrote in
message news:%2****************@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" <du****@exorgroup.comwrote in message
news:O7**************@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

<pthis 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


Oct 17 '06 #3
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)" <No************@comcast.netNoSpamMwrote in
message news:%2****************@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" <du****@exorgroup.comwrote in message
news:O7**************@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

<pthis 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
Oct 17 '06 #4
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
"Michael Hamrah" <mh*****@gmail.comwrote in message
news:11**********************@m7g2000cwm.googlegro ups.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)" <No************@comcast.netNoSpamMwrote in
message news:%2****************@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" <du****@exorgroup.comwrote in message
news:O7**************@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

<pthis 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

Oct 17 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Andy Bates | last post: by
2 posts views Thread by avivgur | last post: by
3 posts views Thread by Jim Heavey | last post: by
5 posts views Thread by Jeremy Ames | last post: by
5 posts views Thread by Web Team | last post: by
9 posts views Thread by Kadett | last post: by
11 posts views Thread by Pete Kane | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.