Don't really know what's wrong but i have an AjaxFileUpload from the ajaxToolKit and in the method in code behind for upload complete i try to fetch the user id from my textbox to link the document to the file uploaded. Somehow, this doesnt seem to work, whats wrong?
Here is my aspx
<div class="floatLeft">
<asp:Label id="idSearchLabel" runat="server" >Employee ID:</asp:Label><br />
<asp:TextBox id="idSearchTextBox" runat="server" CssClass="textbox125" ></asp:TextBox>
<asp:RegularExpressionValidator id="RegularExpressionValidator2" runat="server"
ControlToValidate="idSearchTextBox" ErrorMessage="Can only be digits." Display="Dynamic"
ForeColor="red" ValidationExpression="^[\d]{1,10}" />
</div>
Here is my aspx.cs
protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
{
string filePath = "~/Docs/";
try
{
//get id to attach document to
string id = idSearchTextBox.Text;
if (!String.IsNullOrEmpty(id))
{
//create directory
filePath = filePath + id + "/";
Directory.CreateDirectory(Server.MapPath(filePath));
//save file
filePath = "~/Docs/" + e.FileName;
AjaxFileUpload1.SaveAs(Server.MapPath(filePath));
}
else
{
}
}
catch
{
}
}
Is there something about context involved here? Im so out in the blue.