I need to assign filename name variable to hidden field value in ashx page, how can I assign value to hidden field in ashx page?
.ashx page
public void ProcessRequest(HttpContext context)
{
var file = context.Request.Files[0];
//here i need to pass this file name in hidden field value
}
This is aspx page where hidden filed present
<asp:HiddenField ID="hdnFileName" runat="server"/>
(Unless I’m very much mistaken..) ASHX is a webservice, not some code-behind.
If you want to get the value of that field, you need to post your form to the corresponding URL of the .ASHX file, or use AJAX.
If you want to return data, I advise you to use AJAX.
EDIT: According to MSDN, my statement is correct. .ASHX is ment for HttpHandlers that do not have a UI.
Example of how to post with AJAX:
Your ASHX would return the data:
note: see also https://stackoverflow.com/a/8758614/690178 for uploading files using AJAX.