表单与JQuery

时间:2024-01-11 21:06:32
表单:
Html标签注意:
1.提交action
2.提交按钮:类型一定为type="submit" ,不然无反应
3.
Jquery: 个人认为属于JS
1.一般不用表单提交
2.直接onClick提交给JS中的Jquery,在由Jquery提交给后台并接收Json返回值
=====================================================================================================
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/ViewMasterPageAdmin.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<%@ Import Namespace="CMSLYF.Models.Entity" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
     Index
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div id="LYF_all">
   <img src="../../Content/Image/lyf_siteMapPath.gif" />
    <asp:SiteMapPath ID="SiteMapPath1" runat="server"></asp:SiteMapPath>
    <fieldset id="content_fieldset" style="border:1px solid yellow">           
        <h2>SiteSetting_Index</h2>
        <table>
            <tr style="background-color:#ff6a00;">
                <th>Name</th>
                <th>Value</th>
                <th>操作</th>
            </tr>
            <%foreach(SiteSettingsEntity sse in Model){ %>
            <tr>
                <th><%=sse.Name %></th>
                <th><%=sse.Value %></th>
                <th><a href="javascript:FunShowSiteSetting(<%=sse.SiteSettingId %>)">修改</a>|</th>
            </tr>
            <tr style="background-color:yellow">
                <th></th>
                <th></th>
                <th></th>
            </tr>
            <%} %>
        </table>
      <form action="/SiteSetting/Index" method="post">
        网站设置信息:<br />
        名称:<input type="text" id="Name" name="Name" /><br />
        值  :<input type="text" id="Value" name="Value" /><br />
        <input type="submit" id="ButtonSave" name="" value="保存修改" hidden="hidden" />
        <input type="button" id="ButtonAddSet" name="" value="添加" />
      </form>
 </fieldset>
</div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolderStyle" runat="server">
    <script src="../../Scripts/jquery-1.8.2.js"></script>
    <script type="text/javascript">
        function FunShowSiteSetting(id) {
            $.post("/SiteSetting/SelectSiteSettingById/" + id, function (data) {
                $("#Name").val(data.Name);
                $("#Value").val(data.Value);
                $("#ButtonAddSet").hide();
                $("#ButtonSave").show();
            });
        }
    </script>
</asp:Content>