Getting control ID from Web Parts Zone on Crosspage postback

T

tofu.captain

I have an ASPX page that needs to read in form values (txtbox,
dropdownlists, etc) from a custom control that redirects execution by
crosspage postback. Here is the how it is being redirected:

<asp:Button ID="btnViewReport" runat="server" Text="View Report"
PostBackUrl="~/Viewer.aspx" />

The custom control is sitting in a Web Part Zone Declarative Catalog:

<asp:CatalogZone ID="CatalogZone1" runat="server" >
<ZoneTemplate>
<asp:pageCatalogPart ID="PageCatalogPart1"
runat="server" />
<asp:DeclarativeCatalogPart
ID="DeclarativeCatalogPar1" runat="server">
<WebPartsTemplate>
<PARMS:parameters ID="ucParms"
runat="server" title="ABC" />
</WebPartsTemplate>
</asp:DeclarativeCatalogPart>
</ZoneTemplate>
</asp:CatalogZone>

The ASPX page that is redirected to has code that tries to retrieve the
ID of the control so that it can access and find the values contained
in the custom control's form fields. The problem is that since this is
a Web Part, we may not know which zone it is located in and must thus
loop through all the zones in the web part manager, as such:

WebPartManager wpm = WebPartManager.GetCurrentWebPartManager(page);
if (wpm == null)
throw new Exception(msgNoControlID); //
msgNoControlIID is defined earlier

WebPartZoneBase wz = null; // wpm.Zones[zoneID];

for (int i = 0; i < wpm.Zones.Count; i++)
{
wz = wpm.Zones;
for (int j = 0; j < wz.WebParts.Count; j++)
{
for (int k = 0; k < wz.WebParts[j].Controls.Count;
k++)
{
if (wz.WebParts[j].Controls[k].ID == controlID)
return
wz.WebParts[j].Controls[k].UniqueID.ToString();
}
}
}

throw new Exception("Cannot find Control " + controlID + "
in Zone " + zoneID);

These sets of code (and the code I haven't shown) all works if the
custom control is embedded somewhere as a Web Part Zone instead of a
Declarative Catalog in a Catalog Zone. But once it's only in the
Declarative Catalog, the ASPX page fails to find the custom control's
ID on cross page postback.

My question is this, is there a solution that meets my needs for having
my custom control redirect execution to another ASPX page where it can
read the form values from it without using Session variables or reading
from querystring in the URL?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top