在ASP.NET Web表单使用纯HTML控件表单提交值 [英] Form Post Values using plain html controls in ASP.NET web forms

查看:122
本文介绍了在ASP.NET Web表单使用纯HTML控件表单提交值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的形式与像波纹管使用ASP.NET Web窗体(不MVC)

I have a simple form with some plain html input like bellow using ASP.NET Web Forms (not MVC)

<table id="tbl_SchoolDetails">
    <tbody id="tbody_SchoolDetails">
        <tr>
            <td>
            School Name
        </td>
        <td>
            <input id="SchoolDetails_SchoolName" type="text" value="<%= ViewModel.School.Name %>" />
        </td>
    </tr>
    <tr>
        <td>
            Head Teacher
        </td>
        <td>
            <input id="SchoolDetails_HeadTeacher_Name" type="text" value="<%= ViewModel.School.HeadTeacher.Name %>" />
        </td>
    </tr>
    <tr>
        <td>
            Head Teacher Email
        </td>
        <td>
            <input id="SchoolDetails_HeadTeacher_Email" type="text" value="<%= ViewModel.School.HeadTeacher.Email %>" />
        </td>
    </tr>
    <tr>
        <td>
            Regent/Placement Contact
        </td>
        <td>
            <input id="SchoolDetails_Regent_Name" type="text" value="<%= ViewModel.School.Regent.Name %>" />
        </td>
    </tr>
</tbody>
</table>

当我做了后回的文本框中的值不包含在该元素的Request.Form服务器。有一些原因,我很想念。我不愿意用asp.net控件的页面以后将需要JavaScript的一个合理的数目改变用户界面和其他的东西。

When I do a post back to the server the values of the text boxes are not contained in the Request.Form element. Is there some reason for this that I am missing. I am reluctant to use asp.net controls as the page is later going to require a fair amount of javascript for changing the ui and other stuff.

我知道我可以很容易地MVC做到这一点,但不幸的是更改,这是不是在这个时间的选择。

I know I could easily do this with MVC but unfortunatly a change to this is not an option at this time.

干杯
科林·摹

Cheers Colin G

推荐答案

使输入两个ID和一个名字,看看是否能不能解决你的问题。

Give the input both an id and a name and see if that doesn't solve your problem.

<input id="SchoolDetails_SchoolName"
       name="SchoolDetails_SchoolName"
       type="text"
       value="<%= ViewModel.School.Name %>" />

id属性唯一标识DOM中的代码。该 name属性使这种标签贴追溯到的一部分形成。 ASP.NET控件,或用HTML元素 RUNAT =服务器,自动获得两个指定的名称和id属性。

The id property only identifies the tag within the DOM. The name property allows the tag to be posted back as part of a form. An ASP.NET control, or an HTML element with runat=server, automatically gets both the name and id properties assigned.

这篇关于在ASP.NET Web表单使用纯HTML控件表单提交值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆