在代码后面提交后,表单输入无法被识别

时间:2015-10-30 18:14:45

标签: html forms post

标题说明了一切。我提交了一个表单,在后面的代码中调用一个函数,但是表单的值总是为空。

我已经尝试了很多场景,我会发布我当前的状态,看看是否有一个我缺少的简单修复或更好的解决方案。

我不知道这会影响到什么,但这段代码位于.ascx页面。

相关JS / jQuery

function forceClick() {

    <%= Page.ClientScript.GetPostBackEventReference(hiddenBtn, string.Empty) %>;
    }


$(document).ready(function() {
    $('[id$=ImageButton2]').click(function () {
        console.log($('[id$=buttontest]'));
        console.log($('[id$=ImageButton2]'));
        $("#modal_dialog").dialog({
            title: "Delete Item",
            buttons: {
                Submit: function () {
                    forceClick();
                    $('#myForm').submit();

                    $(this).dialog('close');
                },
                Close: function() {
                    $(this).dialog('close');
                }
            },

            modal: true
        });
        return false;
    });

相关HTML

<div id="modal_dialog" style="display: none">
    <p class="validateTips">Please enter a reason for deleting the item.</p>
    <form name="myForm" id="myForm" method="POST" action="Detail.ascx">
        <input type="text" id="comment" name="comment"/>    
    </form> 
</div>

代码隐藏

    protected void buttontest_OnClick(object sender, EventArgs e)
    {
        string commentOne = Request.Form["comment"];



        Session["ItemCount"] = null;
        if (DeleteItem != null)
        {
            DeleteItem(this, e);
        }
    }

0 个答案:

没有答案
相关问题