Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 2个文本框,2种形式,名称相同_Asp.net_Asp.net Mvc - Fatal编程技术网

Asp.net 2个文本框,2种形式,名称相同

Asp.net 2个文本框,2种形式,名称相同,asp.net,asp.net-mvc,Asp.net,Asp.net Mvc,我在表格上有两个类似的表格块: <form action="/2/All/Home/SubIdeaComment?SubIdeaID=5576&amp;referrerUrl=http%3A%2F%2Flocalhost%3A1261%2F2%2FAll%2FHome%2FIdea%2F5575%3FreferrerUrl%3Dhttp%253A%252F%252Flocalhost%253A1261%252F2" method="post">

我在表格上有两个类似的表格块:

        <form action="/2/All/Home/SubIdeaComment?SubIdeaID=5576&amp;referrerUrl=http%3A%2F%2Flocalhost%3A1261%2F2%2FAll%2FHome%2FIdea%2F5575%3FreferrerUrl%3Dhttp%253A%252F%252Flocalhost%253A1261%252F2" method="post">



        <textarea id="SubComment" name="SubComment" style="width: 80%"></textarea>

        <br />

        <input type="submit" class="InputBtn" value="Reply" />

        <input type="reset" class="InputBtn" onclick="ShowHideReply($('#divSubIdeaReply5576'), $('#subIdeaButtons5576'))"

            value="Cancel" />

        <br />

        <br />

        </form>

但当第一个表单提交时,我的子命令为空。据我所知,原因是两个字段具有相同的名称。但是有不同的形式。。。。如何正确执行?

正如您已经正确假设的那样,
id
-属性必须是唯一的。我不知道这些表单是如何在你的应用程序中生成的,但也许使用可以帮助你。

刚刚看到ASP.NET模板-它生成内部具有相同id的元素
        <form action="/2/All/Home/SubIdeaComment?SubIdeaID=5577&amp;referrerUrl=http%3A%2F%2Flocalhost%3A1261%2F2%2FAll%2FHome%2FIdea%2F5575%3FreferrerUrl%3Dhttp%253A%252F%252Flocalhost%253A1261%252F2" method="post">



        <textarea id="SubComment" name="SubComment" style="width: 80%"></textarea>

        <br />

        <input type="submit" class="InputBtn" value="Reply" />

        <input type="reset" class="InputBtn" onclick="ShowHideReply($('#divSubIdeaReply5577'), $('#subIdeaButtons5577'))"

            value="Cancel" />

        <br />

        <br />

        </form>
    [AcceptVerbs(HttpVerbs.Post)]
    [ValidateInput(false)]
    public ActionResult SubIdeaComment(int SubIdeaID, string SubComment, string referrerUrl)
    {
        if (User.Identity.IsAuthenticated && !String.IsNullOrWhiteSpace(SubComment))
            _repository.AddComment(User.Identity.Name, SubIdeaID, null, SubComment);
        return Redirect(referrerUrl);
    }