ASP.NET页面上的编译器错误,并提交表单



我尝试通过ASP按钮来终止提交。我发现没有定义在'asp.default_aspx。

bootstrapasp.master:

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="BootstrapASP.master.cs" Inherits="Shift.BootstrapASP" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html" charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title>Shift</title>
    <link type="text/css" rel="stylesheet" href="css/bootstrap.css" /> 
    <link type="text/css" rel="stylesheet" href="css/main.css" /> 
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
    <![endif]-->
    <asp:ContentPlaceHolder ID="head" runat="server"></asp:ContentPlaceHolder>
</head>
<body>
    <div>
        <asp:ContentPlaceHolder ID="ContentMain" runat="server"></asp:ContentPlaceHolder>
    </div>
    <script src="js/jquery-1.10.2.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/interactive.js"></script>
</body>
</html>

default.aspx:

<%@ Page Title="Shift" Language="C#" MasterPageFile="~/BootstrapASP.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Shift.WebForm1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"></asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentMain" runat="server">
    <div class="container content-wrapper">
        <form role="form" runat="server">
            <div class="row">
                <div class="col-md-4 col-md-offset-7">
                    <asp:LinkButton ID="SubmitBtn" runat="server" OnClick="SubmitBtn_Click" CssClass="btn btn-danger btn-lg pull-right">
                        <span class="glyphicon glyphicon-import"></span> Senden
                    </asp:LinkButton>
                </div>
            </div>
            <div class="row">
                <div class="col-md-4 col-md-offset-1">
                    <h1>Set Down</h1>
                    <hr />
                    <div id="down-form-holder">
                        <div class="form-group">
                            <label for="old-pc-ci">Computer CI*</label>
                            <input type="text" class="form-control" name="old-pc-ci" id="old-pc-ci" />
                        </div>
                        <div class="form-group">
                            <label for="old-mon-ci">Monitor CI*</label>
                            <input type="text" class="form-control" name="old-mon-ci[]" id="old-mon-ci" />
                        </div>
                    </div>
                    <button type="button" id="old-add-monitor" class="btn btn-default btn-sm pull-right">
                        <span class="glyphicon glyphicon-plus"></span> Monitor
                    </button>
                </div>
            </div>
        </form>
    </div>
</asp:Content>

在default.aspx.cs中,我为" submistbtn_click"创建了一个事件手册default.aspx.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Shift
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }
        void SubmitBtn_Click(Object sender, EventArgs e)
        {
        }
    }
}

c#中的方法默认为私有,因此从标记中看不到单击处理程序。常见的做法是使它们受到保护:

protected void SubmitBtn_Click(Object sender, EventArgs e)

您的事件需要受到保护,您拥有的方式默认为私有:

    protected void SubmitBtn_Click(Object sender, EventArgs e)
    {
    }
 protected void SubmitBtn_Click(object sender, EventArgs e) 
 {
 }
    <asp:LinkButton ID="SubmitBtn" runat="server" OnClick="SubmitBtn_Click" CssClass="btn 
    btn-danger btn-lg pull-right">
    <span class="glyphicon glyphicon-import"></span> Senden</asp:LinkButton>

相关内容

  • 没有找到相关文章

最新更新