I have a repeater that among other controls has an AsyncFileUpload and an error label all embedded inside a panel (regular, not update panel). In AFU's UploadComplete event I need to access the panel and the label; I can access the AFU itself using "sender" argument:
<asp:Repeater runat="server" ID="rpt1" ClientIDMode="Static" OnItemDataBound="rptQuestions_ItemDataBound">
<ItemTemplate>
< other controls>
<asp:Panel runat="server" ID="pnlFU" clientidmode="static">
<ajaxToolkit:AsyncFileUpload runat="server"
ID="fuAttchedDocs"
clientidmode="static"
ThrobberID="myThrobber"
UploaderStyle="Traditional"
OnClientUploadComplete="onClientUploadComplete"
OnUploadedComplete="fuAttchedDocs_UploadedComplete"
OnUploadedFileError="fuAttchedDocs_UploadedFileError" />
<asp:Label runat="server" ID="lblError" clientidmode="static" Text="" CssClass="field-validation-error" Style="display: none" />
</asp:Panel>
</ItemTemplate>
</asp:Repeater>
protected void fuAttchedDocs_UploadedComplete(object sender, AsyncFileUploadEventArgs e)
{
AsyncFileUpload fuAttchedDocs = (AsyncFileUpload)sender;
if (fuAttchedDocs.HasFile)
{
// How do I access these?
lblError.Style["display"] = "none";
....
pnlFU.Style["display"] = "block";
}
}
How do I make sure I am accessing the correct panel and label inside the repeater?
Also, when "Submit" button, located outside repeater, is clicked I am using the following to make sure all files are uploaded at once and call a js function "sendResponse()" that does a postback to deal with all the repeater items.
<button type="submit" class="btn btn-primary btn-md" onclick="javascript:document.forms[0].encoding = 'multipart/form-data';sendResponse();">Submit Response</button>
Does this seem correct? I can't test it until I figure out accessing controls inside repeater but thought I check with you if it makes sense or not.