E
EGI Consulting Jobs
I am trying to build a ASP.Net usercontrol from an XML file or from
the database. I have a .aspx that build dynamically from codebehind.
I am wondering if there is a way to do this same sort of thing but
from an XML document or SQL database. Maybe pull the creation of
TableCells, Textboxes, Validation and create global function to build
these objects. I have run into a brick wall. Maybe someone has also
tried to do something similar.
*********************
Sample: START
*********************
<script language="vb" runat="server">
Sub Page_Load(Src As Object, E As EventArgs)
' This example just injects some plain text
dim whatever as control
whatever=Page.FindControl("celltwo")
whatever.controls.Add(new LiteralControl("Surprise"))
Page.Controls.Add(new LiteralControl("Hello<br>"))
Page.Controls.Add(new LiteralControl("Glad to Meet You<br>"))
' This example injects some table rows and cells
dim r AS new TableRow()
dim c1 as new TableCell()
c1.id="emailtext"
dim c2 as new TableCell()
c2.id="emailctrl"
r.cells.add(c1)
r.cells.add(c2)
r.id="foobar"
t1.rows.add(r)
' This example injects some Web Controls
' into the new rows
' find the cell
dim myemail = new TextBox
myemail.ID = "emailadd"
whatever=Page.FindControl("emailtext")
whatever.controls.Add(new LiteralControl("Email Address"))
' find the cell
whatever=Page.FindControl("emailctrl")
whatever.controls.Add(myemail)
dim myemailvalid = new RequiredFieldValidator
myemailvalid.ErrorMessage = "This is a required field"
myemailvalid.ControlToValidate = "emailadd"
whatever.Controls.Add(myemailvalid)
End Sub
</script>
<html><head>
<title>PageControlsAdd</title>
</head>
<body>
<form id="f1" runat="server">
<asp:Table id="t1" runat="server" GridLines="both"
BorderWidth="1px">
<asp:TableRow>
<asp:TableCell id="cellone">Cell 1</asp:TableCell>
<asp:TableCell id="celltwo">Cell 2</asp:TableCell>
</asp:TableRow>
</asp:table>
<asp:Button id="joincrowd" text="Join The Crowd" runat="server"/>
</form>
</body>
</html>
*********************
Sample: END
*********************
the database. I have a .aspx that build dynamically from codebehind.
I am wondering if there is a way to do this same sort of thing but
from an XML document or SQL database. Maybe pull the creation of
TableCells, Textboxes, Validation and create global function to build
these objects. I have run into a brick wall. Maybe someone has also
tried to do something similar.
*********************
Sample: START
*********************
<script language="vb" runat="server">
Sub Page_Load(Src As Object, E As EventArgs)
' This example just injects some plain text
dim whatever as control
whatever=Page.FindControl("celltwo")
whatever.controls.Add(new LiteralControl("Surprise"))
Page.Controls.Add(new LiteralControl("Hello<br>"))
Page.Controls.Add(new LiteralControl("Glad to Meet You<br>"))
' This example injects some table rows and cells
dim r AS new TableRow()
dim c1 as new TableCell()
c1.id="emailtext"
dim c2 as new TableCell()
c2.id="emailctrl"
r.cells.add(c1)
r.cells.add(c2)
r.id="foobar"
t1.rows.add(r)
' This example injects some Web Controls
' into the new rows
' find the cell
dim myemail = new TextBox
myemail.ID = "emailadd"
whatever=Page.FindControl("emailtext")
whatever.controls.Add(new LiteralControl("Email Address"))
' find the cell
whatever=Page.FindControl("emailctrl")
whatever.controls.Add(myemail)
dim myemailvalid = new RequiredFieldValidator
myemailvalid.ErrorMessage = "This is a required field"
myemailvalid.ControlToValidate = "emailadd"
whatever.Controls.Add(myemailvalid)
End Sub
</script>
<html><head>
<title>PageControlsAdd</title>
</head>
<body>
<form id="f1" runat="server">
<asp:Table id="t1" runat="server" GridLines="both"
BorderWidth="1px">
<asp:TableRow>
<asp:TableCell id="cellone">Cell 1</asp:TableCell>
<asp:TableCell id="celltwo">Cell 2</asp:TableCell>
</asp:TableRow>
</asp:table>
<asp:Button id="joincrowd" text="Join The Crowd" runat="server"/>
</form>
</body>
</html>
*********************
Sample: END
*********************