E
elkay
I am trying to pass Controls dynamically created in UserControl placed
in a placeholder of a page to another page.
How can I get each ID and value of the control in the new page?
Any help will be appreciated.
I have gone through this group and read:
*Creating ASP.NET Server Controls Dynamically....
I am pasting my code for your ref.
<HTML code of Main Form>
<form id="Form1" method="post" runat="server">
<asplaceHolder id="plh1" runat="server"></asplaceHolder><br>
<asplaceHolder id="plh2" runat="server"></asplaceHolder><br>
<asplaceHolder id="plh3" runat="server"></asplaceHolder><br>
<asplaceHolder id="plh4" runat="server"></asplaceHolder><br>
<asp:Button ID="btnSubmit" Runat="server" Text="Submit"
OnClick="btnSubmit_Click"></asp:Button>
<asp:Button ID="btnClear" Runat="server" Text="Clear"
OnClick="btnClear_Click"></asp:Button>
</form>
</HTML Code>
<codebehind for Main Form>
string strControlID=null;
private void Page_Load(object sender, System.EventArgs e){
strControlID=Request.Params["ControlID"];
if (!IsPostBack){
plh1Setup(strControlID);
plh2Setup(strControlID);
plh3Setup(strControlID);
plh4Setup(strControlID);}
//Code for Handling Postback here
}
private void plh1Setup (string sControlID) {
oControl1 = LoadControl("Control1.ascx");
plh1.Controls.Clear();
plh1.Controls.Add(oControl1); }
//Similarly for other place holders
protected void btnSubmit_Click(object sender, System.EventArgs e) {
Server.Transfer("ValidationForm.aspx", true); }
</ codebehind for Main Form>
So far everything is being populated as required....
When I click Submit button, how do I take all the values and ID's of
Parent and Children Controls to the "ValidationForm.aspx"
In the "ValidationForm.aspx", I need to validate the control values and
send the response back to user telling him to fix the values of certain
control OR if the values are right with a message saying that values
submitted successfuly (values were right and inserted or updated in
database).
//FOr testing I am trying to read all the ID's of the controls in the
page_Load of "ValidationForm.aspx"
private void Page_Load(object sender, System.EventArgs e) {
foreach (Control c in ????) //How do I get the controlCollection
{
Response.Write("c.Type:"+c.GetType().ToString().ToString() +"<br>");
Response.Write("c.ID:"+c.ID +"<br>");
Response.Write("C.Value:" + ?? +"<br>"); //How do I get the Value
}
}
Any help would be greatly appreciated.
Thank you in advance.
Elkay
in a placeholder of a page to another page.
How can I get each ID and value of the control in the new page?
Any help will be appreciated.
I have gone through this group and read:
*Creating ASP.NET Server Controls Dynamically....
I am pasting my code for your ref.
<HTML code of Main Form>
<form id="Form1" method="post" runat="server">
<asplaceHolder id="plh1" runat="server"></asplaceHolder><br>
<asplaceHolder id="plh2" runat="server"></asplaceHolder><br>
<asplaceHolder id="plh3" runat="server"></asplaceHolder><br>
<asplaceHolder id="plh4" runat="server"></asplaceHolder><br>
<asp:Button ID="btnSubmit" Runat="server" Text="Submit"
OnClick="btnSubmit_Click"></asp:Button>
<asp:Button ID="btnClear" Runat="server" Text="Clear"
OnClick="btnClear_Click"></asp:Button>
</form>
</HTML Code>
<codebehind for Main Form>
string strControlID=null;
private void Page_Load(object sender, System.EventArgs e){
strControlID=Request.Params["ControlID"];
if (!IsPostBack){
plh1Setup(strControlID);
plh2Setup(strControlID);
plh3Setup(strControlID);
plh4Setup(strControlID);}
//Code for Handling Postback here
}
private void plh1Setup (string sControlID) {
oControl1 = LoadControl("Control1.ascx");
plh1.Controls.Clear();
plh1.Controls.Add(oControl1); }
//Similarly for other place holders
protected void btnSubmit_Click(object sender, System.EventArgs e) {
Server.Transfer("ValidationForm.aspx", true); }
</ codebehind for Main Form>
So far everything is being populated as required....
When I click Submit button, how do I take all the values and ID's of
Parent and Children Controls to the "ValidationForm.aspx"
In the "ValidationForm.aspx", I need to validate the control values and
send the response back to user telling him to fix the values of certain
control OR if the values are right with a message saying that values
submitted successfuly (values were right and inserted or updated in
database).
//FOr testing I am trying to read all the ID's of the controls in the
page_Load of "ValidationForm.aspx"
private void Page_Load(object sender, System.EventArgs e) {
foreach (Control c in ????) //How do I get the controlCollection
{
Response.Write("c.Type:"+c.GetType().ToString().ToString() +"<br>");
Response.Write("c.ID:"+c.ID +"<br>");
Response.Write("C.Value:" + ?? +"<br>"); //How do I get the Value
}
}
Any help would be greatly appreciated.
Thank you in advance.
Elkay