Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Dynamic control on aspx page, dynamic location (http://www.velocityreviews.com/forums/t83218-dynamic-control-on-aspx-page-dynamic-location.html)

Chris Thunell 07-21-2004 01:54 PM

Dynamic control on aspx page, dynamic location
 
I have an aspx web form with a table that i'm sending via response.write...
in one of the cells i would like to put a dynamically created server
control. The amount of rows is variable... so i could have 10 rows /
controls. How do i create a server control that goes into the appropriate
grid cell?

Example:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

'Put user code to initialize the page here

Response.Write("<TABLE id='Table1' cellSpacing='1' cellPadding='1'
width='300' border='1'>")

Response.Write("<TR>")

Response.Write("<TD>Test1</TD>")

Response.Write("<TD>test 2</TD>")

Response.Write("<TD>test 3</TD>")

Response.Write("<TD>")

'insert dynamically created server checkbox control <asp:CheckBox
id='CheckBox1' runat='server'></asp:CheckBox></TD>

Response.Write("</TR>")

Response.Write("<TR>")

Response.Write("<TD>test 4</TD>")

Response.Write("<TD>test 5</TD>")

Response.Write("<TD>test 6</TD>")

Response.Write("<TD>")

'insert dynamically created dropdown server control <asp:DropDownList
id='DropDownList1' runat='server'>

'<asp:ListItem></asp:ListItem>

'<asp:ListItem Value='VA'>VA</asp:ListItem>

'<asp:ListItem Value='MD'>MD</asp:ListItem>

'<asp:ListItem Value='DC'>DC</asp:ListItem>

'</asp:DropDownList>

Response.Write("</TD>")

Response.Write(" </TR>")

Response.Write("</TABLE>")

End Sub



Any help would be greatly appreciated!
Chris Thunell
cthunell@pierceassociates.com





Chris Thunell 07-21-2004 03:04 PM

Re: Dynamic control on aspx page, dynamic location
 
Could you give me an example of that in vb please. I can't seem to get it
to work.

"Eliyahu Goldin" <removemeegoldin@monarchmed.com> wrote in message
news:%23uPLdLzbEHA.3144@TK2MSFTNGP09.phx.gbl...
> Chris,
>
> Response.Write emits html for the client. A server control is processed on
> the server and is rendered to the client as html. Browsers don't know
> anything about <asp:xxx>. You can get server control content with method
> RenderControl and use HtmlTextWriter class for rendering it to clients.
>
> Eliyahu
>
> "Chris Thunell" <cthunell@pierceassociates.com> wrote in message
> news:OpmxXpybEHA.2660@tk2msftngp13.phx.gbl...
> > I have an aspx web form with a table that i'm sending via

> response.write...
> > in one of the cells i would like to put a dynamically created server
> > control. The amount of rows is variable... so i could have 10 rows /
> > controls. How do i create a server control that goes into the

appropriate
> > grid cell?
> >
> > Example:
> > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> > System.EventArgs) Handles MyBase.Load
> >
> > 'Put user code to initialize the page here
> >
> > Response.Write("<TABLE id='Table1' cellSpacing='1' cellPadding='1'
> > width='300' border='1'>")
> >
> > Response.Write("<TR>")
> >
> > Response.Write("<TD>Test1</TD>")
> >
> > Response.Write("<TD>test 2</TD>")
> >
> > Response.Write("<TD>test 3</TD>")
> >
> > Response.Write("<TD>")
> >
> > 'insert dynamically created server checkbox control <asp:CheckBox
> > id='CheckBox1' runat='server'></asp:CheckBox></TD>
> >
> > Response.Write("</TR>")
> >
> > Response.Write("<TR>")
> >
> > Response.Write("<TD>test 4</TD>")
> >
> > Response.Write("<TD>test 5</TD>")
> >
> > Response.Write("<TD>test 6</TD>")
> >
> > Response.Write("<TD>")
> >
> > 'insert dynamically created dropdown server control <asp:DropDownList
> > id='DropDownList1' runat='server'>
> >
> > '<asp:ListItem></asp:ListItem>
> >
> > '<asp:ListItem Value='VA'>VA</asp:ListItem>
> >
> > '<asp:ListItem Value='MD'>MD</asp:ListItem>
> >
> > '<asp:ListItem Value='DC'>DC</asp:ListItem>
> >
> > '</asp:DropDownList>
> >
> > Response.Write("</TD>")
> >
> > Response.Write(" </TR>")
> >
> > Response.Write("</TABLE>")
> >
> > End Sub
> >
> >
> >
> > Any help would be greatly appreciated!
> > Chris Thunell
> > cthunell@pierceassociates.com
> >
> >
> >
> >

>
>




Eliyahu Goldin 07-21-2004 03:53 PM

Re: Dynamic control on aspx page, dynamic location
 
Chris,

Response.Write emits html for the client. A server control is processed on
the server and is rendered to the client as html. Browsers don't know
anything about <asp:xxx>. You can get server control content with method
RenderControl and use HtmlTextWriter class for rendering it to clients.

Eliyahu

"Chris Thunell" <cthunell@pierceassociates.com> wrote in message
news:OpmxXpybEHA.2660@tk2msftngp13.phx.gbl...
> I have an aspx web form with a table that i'm sending via

response.write...
> in one of the cells i would like to put a dynamically created server
> control. The amount of rows is variable... so i could have 10 rows /
> controls. How do i create a server control that goes into the appropriate
> grid cell?
>
> Example:
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
>
> 'Put user code to initialize the page here
>
> Response.Write("<TABLE id='Table1' cellSpacing='1' cellPadding='1'
> width='300' border='1'>")
>
> Response.Write("<TR>")
>
> Response.Write("<TD>Test1</TD>")
>
> Response.Write("<TD>test 2</TD>")
>
> Response.Write("<TD>test 3</TD>")
>
> Response.Write("<TD>")
>
> 'insert dynamically created server checkbox control <asp:CheckBox
> id='CheckBox1' runat='server'></asp:CheckBox></TD>
>
> Response.Write("</TR>")
>
> Response.Write("<TR>")
>
> Response.Write("<TD>test 4</TD>")
>
> Response.Write("<TD>test 5</TD>")
>
> Response.Write("<TD>test 6</TD>")
>
> Response.Write("<TD>")
>
> 'insert dynamically created dropdown server control <asp:DropDownList
> id='DropDownList1' runat='server'>
>
> '<asp:ListItem></asp:ListItem>
>
> '<asp:ListItem Value='VA'>VA</asp:ListItem>
>
> '<asp:ListItem Value='MD'>MD</asp:ListItem>
>
> '<asp:ListItem Value='DC'>DC</asp:ListItem>
>
> '</asp:DropDownList>
>
> Response.Write("</TD>")
>
> Response.Write(" </TR>")
>
> Response.Write("</TABLE>")
>
> End Sub
>
>
>
> Any help would be greatly appreciated!
> Chris Thunell
> cthunell@pierceassociates.com
>
>
>
>




Edward 07-21-2004 04:52 PM

Re: Dynamic control on aspx page, dynamic location
 
you'd better use Table class to generate the output.

Dim tbl as Table
Dim row as TableRow
Dim cell as TableCell

cell.Controls.Add ( your server control )

row.Cells.Add( cell )

tbl.Rows.Add( row )

you'll get the result you need in the client window.


> Could you give me an example of that in vb please. I can't seem to get it
> to work.
>
> "Eliyahu Goldin" <removemeegoldin@monarchmed.com> wrote in message
> news:%23uPLdLzbEHA.3144@TK2MSFTNGP09.phx.gbl...
> > Chris,
> >
> > Response.Write emits html for the client. A server control is processed

on
> > the server and is rendered to the client as html. Browsers don't know
> > anything about <asp:xxx>. You can get server control content with method
> > RenderControl and use HtmlTextWriter class for rendering it to clients.
> >
> > Eliyahu
> >
> > "Chris Thunell" <cthunell@pierceassociates.com> wrote in message
> > news:OpmxXpybEHA.2660@tk2msftngp13.phx.gbl...
> > > I have an aspx web form with a table that i'm sending via

> > response.write...
> > > in one of the cells i would like to put a dynamically created server
> > > control. The amount of rows is variable... so i could have 10 rows /
> > > controls. How do i create a server control that goes into the

> appropriate
> > > grid cell?
> > >
> > > Example:
> > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> > > System.EventArgs) Handles MyBase.Load
> > >
> > > 'Put user code to initialize the page here
> > >
> > > Response.Write("<TABLE id='Table1' cellSpacing='1' cellPadding='1'
> > > width='300' border='1'>")
> > >
> > > Response.Write("<TR>")
> > >
> > > Response.Write("<TD>Test1</TD>")
> > >
> > > Response.Write("<TD>test 2</TD>")
> > >
> > > Response.Write("<TD>test 3</TD>")
> > >
> > > Response.Write("<TD>")
> > >
> > > 'insert dynamically created server checkbox control <asp:CheckBox
> > > id='CheckBox1' runat='server'></asp:CheckBox></TD>
> > >
> > > Response.Write("</TR>")
> > >
> > > Response.Write("<TR>")
> > >
> > > Response.Write("<TD>test 4</TD>")
> > >
> > > Response.Write("<TD>test 5</TD>")
> > >
> > > Response.Write("<TD>test 6</TD>")
> > >
> > > Response.Write("<TD>")
> > >
> > > 'insert dynamically created dropdown server control <asp:DropDownList
> > > id='DropDownList1' runat='server'>
> > >
> > > '<asp:ListItem></asp:ListItem>
> > >
> > > '<asp:ListItem Value='VA'>VA</asp:ListItem>
> > >
> > > '<asp:ListItem Value='MD'>MD</asp:ListItem>
> > >
> > > '<asp:ListItem Value='DC'>DC</asp:ListItem>
> > >
> > > '</asp:DropDownList>
> > >
> > > Response.Write("</TD>")
> > >
> > > Response.Write(" </TR>")
> > >
> > > Response.Write("</TABLE>")
> > >
> > > End Sub
> > >
> > >
> > >
> > > Any help would be greatly appreciated!
> > > Chris Thunell
> > > cthunell@pierceassociates.com
> > >
> > >
> > >
> > >

> >
> >

>
>





All times are GMT. The time now is 10:52 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.