如何从aspx到ashx.cs中选择选项值

时间:2015-10-12 11:30:40

标签: asp.net ashx

我想从选项列表中获取所选值并在ashx.cs页面中查看?我怎么能完成这个任务? 我对ashx文件很新?

  public void ProcessRequest (HttpContext context) 
{
   HttpPostedFile uploads = context.Request.Files["upload"];
   string CKEditorFuncNum = context.Request["CKEditorFuncNum"];
   string file = System.IO.Path.GetFileName(uploads.FileName);
   string DomainName = "http://" +context.Request.ServerVariables["HTTP_HOST"] + "/";
   var filePath = DomainName + "UrlImageService/Images/" + uploads.FileName;
   string CompletePath = context.Server.MapPath("~/Images/") + file;
   uploads.SaveAs(CompletePath);
    //uploads.SaveAs(savePath);              
   //provide direct URL here     
   context.Response.Write("<script>window.parent.CKEDITOR.tools.callFunction("+CKEditorFuncNum + ", \"" + filePath + "\");</script>");
   context.Response.End();    

}
public bool IsReusable { get { return false; } }

我以这种方式调用我的文件

<script type="text/javascript">
    $(function () {
        // Replace the <textarea id="editor1"> with a CKEditor
        // instance, using default configuration.
            CKEDITOR.replace('textEditor', {
            width: '700px',
            height: '300px',
            //filebrowserBrowseUrl: '/uploader/upload.php?type=Files',
            filebrowserUploadUrl: 'Upload.ashx'              
            });               
    });       
</script>

1 个答案:

答案 0 :(得分:0)

您需要以某种方式将该复选框值发送到服务器... 所以也许你的js函数应该将这个值作为查询字符串添加,这样context.Request [“CKEditorFuncNum”]就不会为空。

<script type="text/javascript">
$(function () {
    var checkBoxValue = $("[id$=CKEditorFuncNum]").val();
    // Replace the <textarea id="editor1"> with a CKEditor
    // instance, using default configuration.
        CKEDITOR.replace('textEditor', {
        width: '700px',
        height: '300px',
        //filebrowserBrowseUrl: '/uploader/upload.php?type=Files',
        filebrowserUploadUrl: 'Upload.ashx?CKEditorFuncNum=' + checkBoxValue //here I added the value of the check-box 
        });               
});