简体   繁体   English

在C#中使用ajaxfileupload时从页面获取值

[英]Get value from page when using ajaxfileupload with c#

I'm using the ajaxfileupload from ajaxtoolkit. 我正在使用ajaxtoolkit中的ajaxfileupload。 It sits inside a panel attached to the ajaxpanelextender. 它位于连接到ajaxpanelextender的面板内部。 It works fine. 工作正常。 I click a link inside a grid row which fires a javascript event and the panel pops up with the fileupload control. 我单击网格行内的链接,该链接会触发javascript事件,并且面板会弹出fileupload控件。

function EditInspection(link) {
    // Need to get the inspection id from code behind.
    _InspectionID = link.parentNode.parentNode.cells[0].innerText;
    var id = document.getElementById("ContentPlaceHolder1_InspID");
    id.setAttribute('value', _InspectionID);
    var modal = $('.pop')
    modal.trigger('click');
}

"InspID" is an asp:hidden control inside the panel. “ InspID”是面板内部的asp:hidden控件。

I select my files and click upload to get to the UploadComplete event in C#. 我选择我的文件,然后单击上载以进入C#中的UploadComplete事件。 Once I'm there I need to get a value from the InspID field. 到达那里后,我需要从InspID字段获取一个值。 But when I get to the line 但是当我上线时

string sID = InspID.Value;

the value is always an empty string. 该值始终是一个空字符串。 I also tried using a regular input but the text value is also an empty string. 我也尝试使用常规输入,但文本值也是一个空字符串。 I also tried putting the InspID control outside the panel with the same results. 我还尝试将InspID控件放在面板外部,结果相同。 I looked at the API documentation and it had something specifially for passing data - context keys - but from what I've read, it's not implementd. 我看了一下API文档,它专门用于传递数据-上下文键-但是据我所读,它尚未实现。 I can't change the source code either to implement anything. 我也不能更改源代码来实现任何东西。

How can I set a value from the javascript call and retrieve it from the code behind? 如何从javascript调用中设置一个值并从后面的代码中检索它?

Thank you. 谢谢。

Earlier it was possible so: 较早之前有可能这样:

var id = document.getElementById("<%=InspID.CLientID%>");

When the toolkit passed to DevEx ... 当工具包传递给DevEx ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从AjaxToolkit的AjaxFileUpload事件中的Session或ViewState获取值 - Get value from Session or ViewState in AjaxFileUpload events from AjaxToolkit 无法使用javascript和asp.net从AjaxFileUpload获取文件名 - Cannot get filename from AjaxFileUpload using javascript and asp.net 页面需要登录时如何使用C#从网页获取HTML数据 - How to get HTML data from a webpage using C# when page requires log in 如何使用AjaxFileUpload.js将HTML输入文件传递到C#ASP.Net? - How do you pass HTML input files to C# ASP.Net using AjaxFileUpload.js? C#CompareValidator,使用会话从上一页获取ControlToCompare - C# CompareValidator, Using Session to get ControlToCompare from Previous Page 使用CsvHelper时如何从C#Dynamic对象获取属性名称和值? - How to get property name and value from C# Dynamic object when using CsvHelper? 在C#中仅在get属性中使用默认值时出错 - Error when using default value in only get property in C# 无法使用asp.net C#中的Ajaxfileupload控件上传视频文件,导致出现红色块错误 - Not able to Upload video files using ajaxfileupload control in asp.net c#, results into error with red block 当ID稍有变化时,C#从ID获取值 - C# Get Value from ID when ID changes Slightly 使用C#从CRM 365中的Lookup动态获取价值 - Get Value Dynamically from Lookup in CRM 365 using C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM