G
Guest
I have a Custom WebControl which adds several children at OnInit.
In OnInit I set the ChildControl to ParentID + "_" + Control's ID
so it would be something like MyContainer_VendorID
Now the control is moved to a TableCell in the Control's OnLoad event.
This control still has an ID of MyContainer_VendorID.
the Control is added to the Page. There the control has a value of
MyContainer_VendorID
In the Page's Render statement I overloaded it so i could put a breakpoint
and double check. so i checked myTable.Rows[AnIndex].Cells[5].Controls[0].ID
and sure enough the ID is MyContainer_VendorID.
When the page is rendered however it shows up as VendorID, and I do not see
why. the control always has a value of MyContainer_VendorID
WebControl_OnInit
Create Select
Give It ID OF VendorID
Give it new ID of ID + Vendor so it is now MyContainer_VendorID
AddControl to this.Controls
End Init
WebControl_OnLoad
Transfer all this.Controls to New TableRow as Cells
return this row as a property
Page_OnLoad
add the TableRow to our table
// here the Id is MyContainer_Vendor
Page_Render(
base.Render() //. here the Id is MyContainer_VendorID
now when the page is actually rendered the id is VendorID
I have NO idea how this is possible since before the control is added to the
WebControl's collection it is given the id of MyContainer_VendorID
Actual Debugger Excerpt
tblPOParts.Rows[1].Cells[4].Controls[0].ID "pork0_VendorID" string
protected override void Render(HtmlTextWriter writer)
{
base.Render (writer); // tblPOParts.Rows[1].Cells[4].Controls[0].ID
"pork0_VendorID" string
}
In OnInit I set the ChildControl to ParentID + "_" + Control's ID
so it would be something like MyContainer_VendorID
Now the control is moved to a TableCell in the Control's OnLoad event.
This control still has an ID of MyContainer_VendorID.
the Control is added to the Page. There the control has a value of
MyContainer_VendorID
In the Page's Render statement I overloaded it so i could put a breakpoint
and double check. so i checked myTable.Rows[AnIndex].Cells[5].Controls[0].ID
and sure enough the ID is MyContainer_VendorID.
When the page is rendered however it shows up as VendorID, and I do not see
why. the control always has a value of MyContainer_VendorID
WebControl_OnInit
Create Select
Give It ID OF VendorID
Give it new ID of ID + Vendor so it is now MyContainer_VendorID
AddControl to this.Controls
End Init
WebControl_OnLoad
Transfer all this.Controls to New TableRow as Cells
return this row as a property
Page_OnLoad
add the TableRow to our table
// here the Id is MyContainer_Vendor
Page_Render(
base.Render() //. here the Id is MyContainer_VendorID
now when the page is actually rendered the id is VendorID
I have NO idea how this is possible since before the control is added to the
WebControl's collection it is given the id of MyContainer_VendorID
Actual Debugger Excerpt
tblPOParts.Rows[1].Cells[4].Controls[0].ID "pork0_VendorID" string
protected override void Render(HtmlTextWriter writer)
{
base.Render (writer); // tblPOParts.Rows[1].Cells[4].Controls[0].ID
"pork0_VendorID" string
}