<asp:Panel runat="server" ID="pnlDocUpload">
<div class="row">
<div class="col-md-4">
<div class="column-pad-bottom column-pad-top">Document Title:</div>
<div class="column-pad-bottom2"><asp:TextBox runat="server" ID="fuTitle1" CssClass="form-control"/></div>
<div class="column-pad-bottom2"><asp:TextBox runat="server" ID="fuTitle2" CssClass="form-control"/></div>
<div class="column-pad-bottom2"><asp:TextBox runat="server" ID="fuTitle3" CssClass="form-control"/></div>
<div class="column-pad-bottom2"><asp:TextBox runat="server" ID="fuTitle4" CssClass="form-control"/></div>
<div class="column-pad-bottom2"><asp:TextBox runat="server" ID="fuTitle5" CssClass="form-control"/></div>
<div class="column-pad-bottom2"><asp:TextBox runat="server" ID="fuTitle6" CssClass="form-control"/></div>
<div class="column-pad-bottom2"><asp:TextBox runat="server" ID="fuTitle7" CssClass="form-control"/></div>
<div class="column-pad-bottom2"><asp:TextBox runat="server" ID="fuTitle8" CssClass="form-control"/></div>
<div class="column-pad-bottom2"><asp:TextBox runat="server" ID="fuTitle9" CssClass="form-control"/></div>
<div class="column-pad-bottom2"><asp:TextBox runat="server" ID="fuTitle10" CssClass="form-control"/></div>
<div class="column-pad-bottom2"><asp:TextBox runat="server" ID="fuTitle11" CssClass="form-control"/></div>
<div class="column-pad-bottom2"><asp:TextBox runat="server" ID="fuTitle12" CssClass="form-control"/></div>
</div>
<H3> I tried using find controls it is always returning null </H3>
protected void btAddSection_Click(object sender, EventArgs e)
{
string path = "C:/Users/emahou1/Desktop/testfolder";
if (cbIsLink.Checked == true)
{
if (fuTitleLink.HasFile)
{
// it is other section has nothing to do with the 12 input tags
}
else
{
// get the link path from the text box and save it ??
}
}
else
{
for (int i = 0; i < Request.Files.Count; i++ )
{
string text = "";
for (int t = 1; t <= 5; t++)
{
TextBox tb = FindControl("fuTitle" + t.ToString()) as TextBox;
if (tb != null) text += tb.Text;
}
if (Request.Files[i].FileName.ToString() != "")
{
// here i will collect the files and the textbox values to submit them to database
}
}
}
}
I have 12 input tabs that I will use to upload files to the server, I am already looping throgh the input controls to get the files, but these text boxes i want to loop through them so I can capture the text entered by the user and use that text to rename each file being uploaded ....
Page_Loadmethod..this could be a PostBack problem would need to see how you are Invoking the code in your for loop.. also are you familiar with doing aforeach(Control ctrl in Controls)for example.. ?