不知道什么是错的,但是我从ajaxToolKit获得了一个AjaxFileUpload,并且在代码后面的方法中用于上传完成我尝试从我的文本框中获取用户ID以将文档链接到上传的文件。 不知何故,这似乎没有用,什么错?
这是我的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>这是我的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 { } }这里涉及上下文吗? 我是如此突然出现。
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.
最满意答案
问题解决了,我将文本框中的值放入会话中,因为我可以从UpLoadComplete到达会话变量,所有内容都像魅力一样。
Problem solved, I put the value from textbox into session and since I can reach the session variables from the UpLoadComplete everything works like a charm.
更多推荐
id,AjaxFileUpload,filePath,idSearchTextBox,电脑培训,计算机培训,IT培训"/> <me
发布评论