【发布时间】:2012-02-22 04:37:57
【问题描述】:
在我的 Web 应用程序中,我有一个主 aspx 页面,其中我有一个按钮单击该 btn 单击我正在调用一个 ascx Web 用户控件,因为我正在使用一个 javascript,我试图通过它将数据发布到同样的 ascx,据我所知,我们可以在 ascx 页面中发布数据.. 但我想发布这怎么可能?
xhr.open('POST', '../test.ascx?Id=' + <%=Id%>, true); //Id is the property in ascx page
xhr.setRequestHeader('FILENAME', file.name);
xhr.send(file);
和 onInit ..
if (!string.IsNullOrEmpty(Request.Headers["FileName"]))
{
string Name = Request.Headers["FileName"].ToString();
Stream Stream1 = Request.InputStream;
Add(Name, Stream1, Id);
}
【问题讨论】:
-
ascx???您无法访问用户控件,因为它们无法从外部路径访问..您应该使用 httphandlers/webmethods.. 看到这个stackoverflow.com/questions/579024/…
-
那我如何将文件发送给处理程序?
标签: c# javascript asp.net post