aspx命名空间后出现不包含“XXXX”控件的定义

IT_CoryCheung 2014-04-09 03:19:37
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
namespace EVS.Web.Controls
{
public partial class AdminLogin_NewsAdd : System.Web.UI.Page
{
public string ContentEdit = ""; //文本编辑器
public string NewsHot;
protected void Page_Load(object sender, EventArgs e)
{
if (null == Session["AdminNick"])
{
Response.Redirect("login.aspx");
}
if (!IsPostBack)
{
//显示自己的部门
if (null != Session["DepName"])
{
this.TextBox1.Text = Session["DepName"] as string;
}

if (null != Session["DepId"])
{
this.HiddenField1.Value = Session["DepId"] as string;
}

//取出栏目
string ColumnSql = " select menuname,menuid from menumanagement where depid= " + HiddenField1.Value + " and menutype='文字列表类' and delsign=1";
DataSet ColumnDs = manager.connstr.DataAdapter(ColumnSql);
if (ColumnDs.Tables[0].Rows.Count >= 0)
{
this.DropDownList1.DataSource = ColumnDs;
this.DropDownList1.DataTextField = "MenuName";
this.DropDownList1.DataValueField = "MenuId";
this.DropDownList1.DataBind();
}

//取出候选的用户组
string AuthoritySql = " select usergroupname,groupid from UserGroup where delsign=1";
DataSet AuthorityDS = manager.connstr.DataAdapter(AuthoritySql);
if (AuthorityDS.Tables[0].Rows.Count >= 0)
{
this.CheckBoxList1.DataSource = AuthorityDS;
this.CheckBoxList1.DataTextField = "UserGroupName";
this.CheckBoxList1.DataValueField = "GroupID";
this.CheckBoxList1.DataBind();
}


}
}
public void Button1_Click(object sender, EventArgs e)
{
//获取信息插入数据库
string NewsTitle = TextBox2.Text.ToString().Trim();
string NewsContent = Request.Params["textarea1"];
if (CheckBox1.Checked == true)
{
NewsHot = "1";
}
else
{
NewsHot = "0";
}
//bool NewsHot = CheckBox1.Checked;
string Sequence = TextBox3.Text.ToString();
string DepId = HiddenField1.Value;
string MenuId = DropDownList1.SelectedValue.ToString();
string strCollected = string.Empty;
//获取已选的checklistbox的值,并组成字符串
for (int i = 0; i < CheckBoxList1.Items.Count; i++)
{
if (CheckBoxList1.Items[i].Selected)
{
if (strCollected == string.Empty)
{
strCollected = CheckBoxList1.Items[i].Value;
}
else
{
strCollected = strCollected + "-" + CheckBoxList1.Items[i].Value;
}
}
}
string UserAuthor = strCollected;
//DateTime Time= DateTime.Now;
//bool DelSign = true;
string InsertSql = "insert into NewsList (newstitle,newscontent,newshot,sequence,depid,menuid,userauthor) values('" +
NewsTitle + "', '" + NewsContent + "', " + NewsHot + ", '" + Sequence + "', '" + DepId + "', '" + MenuId + "', '" + UserAuthor + "')";
ShowMessage.ShowAlert(InsertSql);
int SaveSign = manager.connstr.exccute_del(InsertSql);
if (SaveSign > 0)
{
ShowMessage.ShowAlert("保存成功");
}
else
{
ShowMessage.ShowAlert("很遗憾,保存出错,麻烦你重新输入一遍");
}

}
}
}
...全文
136 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
弑天屠龙 2014-04-09
  • 打赏
  • 举报
回复
选中DropDownList1控件,右键 >> 转到定义 >> 重新开一行,定义下CheckBoxList1控件,格式你可以参照其他控件的定义 >> 定义完后保存。 搞定 若是实在看不懂怎么去定义,大不了重新拖个控件,不就行了~
IT_CoryCheung 2014-04-09
  • 打赏
  • 举报
回复
引用 4 楼 FoxDave 的回复:
在同命名空间下找不到定义,统一命名空间
其实我是想在另外一个ashx里调用aspx里的一个方法,但是我在ashx里写代码时,没法调用,我就想是不是没有没有namespace。
IT_CoryCheung 2014-04-09
  • 打赏
  • 举报
回复
引用 5 楼 u013116426 的回复:
AdminLogin_NewsAdd 和前台的命名是不是一样的,还不行重新建页面再赋值过去吧!
<%@ Page Title="" Language="C#" MasterPageFile="~/AdminLogin/MasterPage.master" AutoEventWireup="true" CodeFile="NewsAdd.aspx.cs" Inherits="AdminLogin_NewsAdd" %>
IT_CoryCheung 2014-04-09
  • 打赏
  • 举报
回复
引用 1 楼 u010781074 的回复:
啥意思?没明白啊。。
___紫菜 2014-04-09
  • 打赏
  • 举报
回复
AdminLogin_NewsAdd 和前台的命名是不是一样的,还不行重新建页面再赋值过去吧!
Justin-Liu 2014-04-09
  • 打赏
  • 举报
回复
在同命名空间下找不到定义,统一命名空间
IT_CoryCheung 2014-04-09
  • 打赏
  • 举报
回复
引用 1 楼 u010781074 的回复:
啥意思?没明白啊。。
就是做写了namespace后,CheckBoxList1这些控件会报错,说没定义
IT_CoryCheung 2014-04-09
  • 打赏
  • 举报
回复
引用 楼主 zhfjet 的回复:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
namespace EVS.Web.Controls
{
    public partial class AdminLogin_NewsAdd : System.Web.UI.Page
    {
        public string ContentEdit = "";     //文本编辑器
        public string NewsHot;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (null == Session["AdminNick"])
            {
                Response.Redirect("login.aspx");
            }
            if (!IsPostBack)
            {
                //显示自己的部门
                if (null != Session["DepName"])
                {
                    this.TextBox1.Text = Session["DepName"] as string;
                }

                if (null != Session["DepId"])
                {
                    this.HiddenField1.Value = Session["DepId"] as string;
                }

                //取出栏目
                string ColumnSql = " select menuname,menuid from menumanagement where depid= " + HiddenField1.Value + " and menutype='文字列表类'  and delsign=1";
                DataSet ColumnDs = manager.connstr.DataAdapter(ColumnSql);
                if (ColumnDs.Tables[0].Rows.Count >= 0)
                {
                    this.DropDownList1.DataSource = ColumnDs;
                    this.DropDownList1.DataTextField = "MenuName";
                    this.DropDownList1.DataValueField = "MenuId";
                    this.DropDownList1.DataBind();
                }

                //取出候选的用户组
                string AuthoritySql = " select usergroupname,groupid from UserGroup where delsign=1";
                DataSet AuthorityDS = manager.connstr.DataAdapter(AuthoritySql);
                if (AuthorityDS.Tables[0].Rows.Count >= 0)
                {
                    this.CheckBoxList1.DataSource = AuthorityDS;
                    this.CheckBoxList1.DataTextField = "UserGroupName";
                    this.CheckBoxList1.DataValueField = "GroupID";
                    this.CheckBoxList1.DataBind();
                }


            }
        }
        public void Button1_Click(object sender, EventArgs e)
        {
            //获取信息插入数据库
            string NewsTitle = TextBox2.Text.ToString().Trim();
            string NewsContent = Request.Params["textarea1"];
            if (CheckBox1.Checked == true)
            {
                NewsHot = "1";
            }
            else
            {
                NewsHot = "0";
            }
            //bool NewsHot = CheckBox1.Checked;
            string Sequence = TextBox3.Text.ToString();
            string DepId = HiddenField1.Value;
            string MenuId = DropDownList1.SelectedValue.ToString();
            string strCollected = string.Empty;
            //获取已选的checklistbox的值,并组成字符串
            for (int i = 0; i < CheckBoxList1.Items.Count; i++)
            {
                if (CheckBoxList1.Items[i].Selected)
                {
                    if (strCollected == string.Empty)
                    {
                        strCollected = CheckBoxList1.Items[i].Value;
                    }
                    else
                    {
                        strCollected = strCollected + "-" + CheckBoxList1.Items[i].Value;
                    }
                }
            }
            string UserAuthor = strCollected;
            //DateTime Time= DateTime.Now;
            //bool DelSign = true;
            string InsertSql = "insert into NewsList (newstitle,newscontent,newshot,sequence,depid,menuid,userauthor) values('" +
                                NewsTitle + "', '" + NewsContent + "', " + NewsHot + ", '" + Sequence + "', '" + DepId + "', '" + MenuId + "', '" + UserAuthor + "')";
            ShowMessage.ShowAlert(InsertSql);
            int SaveSign = manager.connstr.exccute_del(InsertSql);
            if (SaveSign > 0)
            {
                ShowMessage.ShowAlert("保存成功");
            }
            else
            {
                ShowMessage.ShowAlert("很遗憾,保存出错,麻烦你重新输入一遍");
            }

        }
    }
}
就是做写了namespace后,CheckBoxList1这些控件会报错,说没定义
刘小安 2014-04-09
  • 打赏
  • 举报
回复
啥意思?没明白啊。。

62,266

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧