开发者

Other Files Do Not Recognize My Static Class - ASP.NET and C#

开发者 https://www.devze.com 2022-12-20 04:43 出处:网络
SqlConnectionStringBuilder resides in System.Data.SqlClient namespace. I imported the name space at the top, but the SqlConnectionStringBuilder doesn\'t get highlighted, the font remains in the black
  1. SqlConnectionStringBuilder resides in System.Data.SqlClient namespace. I imported the name space at the top, but the SqlConnectionStringBuilder doesn't get highlighted, the font remains in the black color. Any idea why does this happen?

  2. RestaurantData is a public static as you see below. I called this static class in Default aspx code behind page as:

RestaurantData.SetUpSessionVariables(Session);

I get the following error:

The name 'RestaurantData' does not exist in the 开发者_JS百科current context

RestaurantData is static, i shouldn't get this error. Can you please advise...


Sounds like you don't have the namespace available to the aspx page.

check this article ... http://www.west-wind.com/WebLog/posts/753705.aspx

try adding this to right after your <%@Page ,,,,,, %> tag:

<%@ Import Namespace="Your.Name.Space" %>

if you're using 3.5 check here http://msdn.microsoft.com/en-us/library/ms164642.aspx

try using a

you can add something like this to your web.config file

<pages>
   <namespaces>
      <add namespace="System" />
      <add namespace="System.Collections" />
      <add namespace="System.Collections.Specialized" />
      <add namespace="System.Configuration" />
      <add namespace="System.Text" />
      <add namespace="System.Text.RegularExpressions" />
      <add namespace="System.Web" />
      <add namespace="System.Web.Caching" />
      <add namespace="System.Web.SessionState" />
      <add namespace="System.Web.Security" />
      <add namespace="System.Web.Profile" />
      <add namespace="System.Web.UI" />
      <add namespace="System.Web.UI.WebControls" />
      <add namespace="System.Web.UI.WebControls.WebParts" />
      <add namespace="System.Web.UI.HtmlControls" />
   </namespaces>
   <!-- Other elements -->
</pages>


For SqlConnectionStringBuilder, have you added a reference to System.Data.dll?

You might need to add a using namespace directive to import the namespace for RestaurantData, e.g.

using MyWebsite.Data;

0

精彩评论

暂无评论...
验证码 换一张
取 消