在Visual Studio 2012中无法识别ASP标记

时间:2015-01-22 21:52:04

标签: c# asp.net visual-studio-2012 reference ajaxcontroltoolkit

我在VS 2012中创建了一个简单的ASP.NET项目但它没有识别AJAX Control Toolkit控件......我已经下载并将ACT添加到我的工具箱中。我在项目页面的构建中引用了DLL ...解决方案无法理解下拉控件上的前缀asp是什么......

更新!

问题不在于"'

更新2!

更改了web.config并稍微重构了代码,但仍然无法识别asp前缀......

错误 enter image description here

解决方案资源管理器

enter image description here

的web.config

<?xml version="1.0"?>
<configuration>
  <!--
    For a description of web.config changes for .NET 4.5 see http://go.microsoft.com/fwlink/?LinkId=235367.

    The following attributes can be set on the <httpRuntime> tag.
      <system.Web>
        <httpRuntime targetFramework="4.5" />
      </system.Web>
  -->
  <system.web>
    <compilation debug="true" targetFramework="4.5"/>
    <httpRuntime/>
    <pages>
      <controls>
        <add tagPrefix="ajax" namespace="AjaxControlToolkit" assembly="AjaxControlToolkit"/>
      </controls>
    </pages>
  </system.web>
  <appSettings>
    <!-- add folder path here-->
    <add key="ediConfigPath" value="~/"/>
  </appSettings>
  <connectionStrings>
    <add name="cmsDB3ConnectStr" connectionString="xkcd" providerName="System.Data.SqlClient"/>
  </connectionStrings>
</configuration>

aspx页面

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>xkcdCoder</title>
    <link type="text/css" rel="stylesheet" href="Content/bootstrap.min.css" />
    <link type="text/css" rel="stylesheet" href="Content/style.css" />
</head>
<body>
    <form id="form1" runat="server">
        <nav id="navbar" class="navbar navbar-default navbar-fixed-top">
            <a id="product" class="navbar-brand">xkcdCoder > TransCodes</a>
            <img id="logo" class="navbar-brand" src="/content/img/xkcd_logo2.png" alt="" />
        </nav>
        <section class="login-sect">
            <asp:dropdownlist id="ddHospitals" runat="server" datatextfield='<%#Eval("Custom")%>' datavaluefield='<%#Eval("Custom")%>' xmlns:asp="#unknown">
            </asp:dropdownlist>
            <div class="give-me-space">
                <div class="give-me-space">TranCode</div>
                <input type="text" />
            </div>
            <div class="give-me-space">
                <div class="give-me-space">TranDescr</div>
                <input type="text" />
            </div>
            <div class="give-me-space">
                <div class="give-me-space">PosTranCode</div>
                <input type="text" />
            </div>
            <div class="give-me-space">
                <div class="give-me-space">NegTranCode</div>
                <input type="text" />
            </div>
            <button type="button" title="Submit" class="action-button">Add Code</button>
        </section>
        <script src="scripts/jquery-1.9.1.min.js"></script>
        <script src="scripts/bootstrap.min.js"></script>
        <script src="Scripts/xkcdCoder.js"></script>
    </form>
</body>
</html>

代码

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;

public partial class _Default : System.Web.UI.Page
{
    public DataSet GetItems()
    {
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["cmsDB3ConnectStr"].ConnectionString);
        SqlCommand cmd = new SqlCommand("getFacilitiesAll", con);
        cmd.CommandType = CommandType.StoredProcedure;
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        try
        {
            con.Open();
            da.Fill(ds);
            con.Close();
        }
         catch (Exception ex)
    {
        string err = ex.ToString(); //write error message
    }
    return ds;
}
protected void Page_Load(object sender, EventArgs e)
{
    if (IsPostBack) 
    {
        return; //This will make sure that only once the below code will be executed.
    } else {
            ddHospitals.DataSource = GetItems();
            ddHospitals.DataBind();
        }
    }
}

0 个答案:

没有答案