“您是否缺少using指令或程序集引用?” C#ASP.NET错误

时间:2018-07-23 11:18:40

标签: c# asp.net

我是C#ASP.NET的业余程序员。我决定创建一个博客,在为博客文章创建页面时偶然发现了这个问题。

错误:

  

'adminpanel_aspx'不包含'submit_btn'的定义,并且   没有扩展方法'submit_btn'接受类型的第一个参数   可以找到“ adminpanel_aspx”(您是否缺少using指令或   组装参考?)

An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

但是,即使我已经在按钮后面加上了代码,也无法解决问题。

This is the properties for the button

一些其他信息:

前端按钮代码:

    <asp:Button ID="post_submit_btn" runat="server" Text="Save Changes" CssClass="btn btn-primary" OnClick="submit_btn" OnDataBinding="submit_btn"  />

我的参考

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
using System.Data;

后面代码中的commit_btn方法:

private void submit_btn(object sender, EventArgs e)
        {
            Button button = post_submit_btn; 
          button = sender as Button; 

            string blogtitle;
            string blogdes;
            string docPath = @"~/Data/blog_post.xml";
            XmlDocument xml_doc = new XmlDocument();
            xml_doc.Load(Server.MapPath(docPath));
            XmlNode root;
            root = xml_doc.DocumentElement;

            blogtitle = blog_title.Text.ToString();
            blogdes = blog_des.Value.ToString();

            XmlNode postNode = xml_doc.CreateElement("post-name");
            XmlNode desNode = xml_doc.CreateElement("description");
            XmlNode timeNode = xml_doc.CreateElement("date");
            XmlNode autherNode = xml_doc.CreateElement("Auther");

            postNode.InnerText = blogtitle;
            desNode.InnerText = blogdes;

            postNode.AppendChild(desNode);
            xml_doc.Save(Server.MapPath(docPath));


        }

0 个答案:

没有答案