.Net validation controls error: 'are you missing a using directive

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?Q2hyaXMgSGFsY3Jvdw==?=

    .Net validation controls error: 'are you missing a using directive

    Hi there

    I've successfully added some .NET validation controls to a page (using
    <asp:RequiredFi eldValidator ...), however when I try to set the 'display'
    property to 'dynamic', my page then throws up the following error in the
    browser:

    CS1061: 'System.Web.UI. WebControls.Tex tBox' does not contain a definition
    for 'Web' and no extension method 'Web' accepting a first argument of type
    'System.Web.UI. WebControls.Tex tBox' could be found (are you missing a using
    directive or an assembly reference?)

    I had the same error when I tried to get a 'CompareValidat or' to work, even
    though I wasn't doing anything with the 'display' property (eventually gave
    up and used a custom validator).

    Code behind for the page specifies the following namespaces (I'm using C#):

    using System
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.H tmlControls;
    using System.Web.UI.W ebControls;
    using System.Web.UI.W ebControls.WebP arts;

    I'm using a master page, and the same namespaces are specified in the
    code-behind for the master page

    I've tried adding system.web as a reference to my project, still no luck.
    Does anyone have a solution for this? Any replies gratefully received!

    Thanks in advance, Chris :)
  • Gaurav Vaish \(a.k.a. MasterGaurav\)

    #2
    Re: .Net validation controls error: 'are you missing a using directive

    CS1061: 'System.Web.UI. WebControls.Tex tBox' does not contain a definition
    for 'Web' and no extension method 'Web' accepting a first argument of type
    'System.Web.UI. WebControls.Tex tBox' could be found (are you missing a
    using
    directive or an assembly reference?)
    Seems like:

    1) You're using ASP.Net 3.5
    2) You're trying to set the property "Web" of "TextBox" either in
    code-beside or in the aspx page.

    Check if accidently there's Web='Something' in aspx page.

    It's actually not really about namespaces it seems, but what controls you're
    using and what code you've written.

    --
    Happy Hacking,
    Gaurav Vaish


    ---------------------------


    Comment

    • =?Utf-8?B?Q2hyaXMgSGFsY3Jvdw==?=

      #3
      Re: .Net validation controls error: 'are you missing a using direc

      Hi Gaurav

      Thanks for the very quick reply. You're right that I'm using .NET 3.5.
      Unfortunately, your suggestion is not the cause of the problem - I'm not
      trying to set a property 'Web' equal to anything in code. The class in the
      code behind is defined as:

      public partial class RecordDetails : System.Web.UI.P age

      I think that this means that the partial class inherits from
      System.Web.UI.P age? Don't know if this gives any clues.

      My code for the validators and the control they should validate is as follows:

      <asp:TextBox ID="Reavailable From" runat="server"
      CssClass="input Box"></asp:TextBox>
      <asp:RequiredFi eldValidator
      ID="Reavailable FromRequiredVal idator" runat="server"
      ErrorMessage="Y ou must enter an estimate for 'Unavailable
      To'" ControlToValida te="Reavailable From"
      Style="margin-left: 15px"
      EnableClientScr ipt="False"></asp:RequiredFie ldValidator>
      <asp:CompareVal idator ID="Reavailable FromCompareVali dator"
      ControlToCompar e="UnavailableF rom" runat="server"
      ErrorMessage="C ompareValidator " Operator="Great erThan"
      Type="Date"></asp:CompareVali dator>

      As I've mentioned, the RequiredFieldVa lidator on its own works, but as soon
      as I add the code for the CompareValidato r control, I get the error.

      Any ideas? This has stumped at least two senior developers and me so far!

      Thanks again, Chris



      "Gaurav Vaish (a.k.a. MasterGaurav)" wrote:
      CS1061: 'System.Web.UI. WebControls.Tex tBox' does not contain a definition
      for 'Web' and no extension method 'Web' accepting a first argument of type
      'System.Web.UI. WebControls.Tex tBox' could be found (are you missing a
      using
      directive or an assembly reference?)
      >
      Seems like:
      >
      1) You're using ASP.Net 3.5
      2) You're trying to set the property "Web" of "TextBox" either in
      code-beside or in the aspx page.
      >
      Check if accidently there's Web='Something' in aspx page.
      >
      It's actually not really about namespaces it seems, but what controls you're
      using and what code you've written.
      >
      --
      Happy Hacking,
      Gaurav Vaish


      ---------------------------
      >
      >
      >

      Comment

      • Peter Duniho

        #4
        Re: .Net validation controls error: 'are you missing a using direc

        On Thu, 24 Jul 2008 16:26:01 -0700, Chris Halcrow
        <ChrisHalcrow@d iscussions.micr osoft.comwrote:
        Hi Gaurav
        >
        Thanks for the very quick reply. You're right that I'm using .NET 3.5.
        Unfortunately, your suggestion is not the cause of the problem - I'm not
        trying to set a property 'Web' equal to anything in code.
        You may not be doing so explicitly. But you must be doing so _somehow_,
        otherwise the compiler wouldn't generate that error message.
        The class in the
        code behind is defined as:
        >
        public partial class RecordDetails : System.Web.UI.P age
        >
        I think that this means that the partial class inherits from
        System.Web.UI.P age? Don't know if this gives any clues.
        I don't see how it would.

        Nothing you've posted so far includes a reference to a "Web" method
        anywhere. But the error message makes it pretty clear that some code is
        trying to reference a "Web" method on the TextBox class.

        The fact is, the C# newsgroup is a pretty poor place to look for answers
        to questions like this anyway. Your issues seems strongly related to your
        use of ASP, and I'm pretty sure there's an ASP.NET newsgroup where your
        question would likely be much more familiar to those reading it.

        But if you really want to get help in this newsgroup, you'll need to post
        a concise-but-complete code sample that reliably demonstrates the problem,
        so that the people reading your post can figure out how the reference to
        "Web" is getting made. I don't think there's any way to answer the
        question without that sort of information.

        Pete

        Comment

        • Peter Duniho

          #5
          Re: .Net validation controls error: 'are you missing a using direc

          On Thu, 24 Jul 2008 16:26:01 -0700, Chris Halcrow
          <ChrisHalcrow@d iscussions.micr osoft.comwrote:
          [...]
          <asp:CompareVal idator ID="Reavailable FromCompareVali dator"
          ControlToCompar e="UnavailableF rom" runat="server"
          ErrorMessage="C ompareValidator " Operator="Great erThan"
          Type="Date"></asp:CompareVali dator>
          >
          As I've mentioned, the RequiredFieldVa lidator on its own works, but as
          soon
          as I add the code for the CompareValidato r control, I get the error.
          >
          Any ideas? This has stumped at least two senior developers and me so
          far!
          By the way, this may be nothing, but...

          I note in the example on MSDN that the declaration for the
          CompareValidato r includes a "ControlToValid ate" field, whereas yours does
          not.

          I don't know why that would cause the error you're seeing, and knowing so
          little about ASP.NET I don't even know if that's a problem at all. But I
          thought I'd mention it.

          Pete

          Comment

          • =?Utf-8?B?Q2hyaXMgSGFsY3Jvdw==?=

            #6
            Re: .Net validation controls error: 'are you missing a using direc

            Hi Peter

            Thanks for the advice. I don't know where the ASP.NET forum is, and Visual
            C# .NET was the closest I could find. Do you have a link to a more
            appropriate forum?

            I'm confident that the missing "ControlToValid ate" property is unrelated to
            this issue

            Thanks again, Chris

            "Peter Duniho" wrote:
            On Thu, 24 Jul 2008 16:26:01 -0700, Chris Halcrow
            <ChrisHalcrow@d iscussions.micr osoft.comwrote:
            >
            [...]
            <asp:CompareVal idator ID="Reavailable FromCompareVali dator"
            ControlToCompar e="UnavailableF rom" runat="server"
            ErrorMessage="C ompareValidator " Operator="Great erThan"
            Type="Date"></asp:CompareVali dator>

            As I've mentioned, the RequiredFieldVa lidator on its own works, but as
            soon
            as I add the code for the CompareValidato r control, I get the error.

            Any ideas? This has stumped at least two senior developers and me so
            far!
            >
            By the way, this may be nothing, but...
            >
            I note in the example on MSDN that the declaration for the
            CompareValidato r includes a "ControlToValid ate" field, whereas yours does
            not.
            >
            I don't know why that would cause the error you're seeing, and knowing so
            little about ASP.NET I don't even know if that's a problem at all. But I
            thought I'd mention it.
            >
            Pete
            >

            Comment

            • Peter Duniho

              #7
              Re: .Net validation controls error: 'are you missing a using direc

              On Thu, 24 Jul 2008 17:42:03 -0700, Chris Halcrow
              <ChrisHalcrow@d iscussions.micr osoft.comwrote:
              Hi Peter
              >
              Thanks for the advice. I don't know where the ASP.NET forum is, and
              Visual
              C# .NET was the closest I could find. Do you have a link to a more
              appropriate forum?
              Not off-hand, no. Sorry. I'm sure I couldn't find it any faster than you
              could yourself, but I do know I've seen mention of it in this newsgroup,
              so you might start by searching this newsgroup for those mentions (you
              might try using the Google Groups archive, rather than Microsoft's portal,
              if the Microsoft search isn't flexible enough).

              Pete

              Comment

              • Gaurav Vaish \(a.k.a. MasterGaurav\)

                #8
                Re: .Net validation controls error: 'are you missing a using direc

                Thanks for the very quick reply. You're right that I'm using .NET 3.5.
                Unfortunately, your suggestion is not the cause of the problem - I'm not
                trying to set a property 'Web' equal to anything in code. The class in
                the
                code behind is defined as:
                >
                public partial class RecordDetails : System.Web.UI.P age
                Can you please post across both the files - aspx and code-beside?

                Or if it's too public a forum... mail at gaurav[~dot~]vaish[~at~]gmail.



                --
                Happy Hacking,
                Gaurav Vaish | http://dwt.sourceforge.net
                http://blogs.mastergaurav.com | http://eduzine.edujini-labs.com
                --------------------------------




                Comment

                • =?Utf-8?B?Q2hyaXMgSGFsY3Jvdw==?=

                  #9
                  Re: .Net validation controls error: 'are you missing a using direc

                  Hi Guarav

                  I got rid of the offending code, to move onto something else, however I keep
                  getting a similar error every time I try to add any slightly unusual property
                  to a control, for example in the following page of aspx code, I've specified
                  RepeatDirection ="Horizontal " as a property of the RadioButtonList , and I get
                  a very similar error ('System.Web.UI .WebControls.Te xtBox' does not contain a
                  definition for 'Web'). Before you ask, the error does say 'TextBox', but
                  identifies the RadioButtonList as the source of the problem. I've also
                  listed the code behind and the master page code and code behind:

                  -----EditSystem.aspx-----------

                  <%@ Page Language="C#" MasterPageFile= "~/master/default.master"
                  AutoEventWireup ="true"
                  CodeFile="EditS ystem.aspx.cs" Inherits="Admin _AddSystem" Title="Untitled
                  Page" %>

                  <asp:Content ID="htmlTitle" ContentPlaceHol derID="htmlTitl e" runat="Server">
                  IST Systems Status - Edit System
                  </asp:Content>
                  <asp:Content ID="head" ContentPlaceHol derID="head" runat="Server">
                  </asp:Content>
                  <asp:Content ID="dropDownMen us" ContentPlaceHol derID="dropDown Menus"
                  runat="Server">
                  <li><a href="/system_status/" title="Go to home page"
                  menu="home">Hom e</a></li>
                  <!--<li><a href="#" menu="menu2">Dr op-down menu</a></li>-->
                  <li id="active"><a href="/system_status/Admin/ManageStatus.as px"
                  title="Update system(s) including current status">
                  Update Systems</a></li>
                  <li id="help"><a href="/system_status/help.aspx" title="Help information"
                  menu="help">
                  Help</a></li>
                  </asp:Content>
                  <asp:Content ID="breadcrumb " ContentPlaceHol derID="breadcru mb" runat="Server">
                  <div class="breadcru mb">
                  <a href=''>IST</a/ <a href="/system_status/">
                  System Status</a/ Update Systems / <a
                  href="/system_status/Admin/ManageSystems.a spx">
                  Manage Systems</a/ Edit System
                  </div>
                  </asp:Content>
                  <asp:Content ID="main" ContentPlaceHol derID="main" runat="Server">
                  <form id="form1" runat="server" class="flow">
                  <br />
                  <div style="margin-left: 40px">
                  <h2>
                  Edit System</h2>
                  <br />
                  <br />
                  <fieldset class="float">
                  <br />
                  <table class="editSyst emDetailsTable" >
                  <tr>
                  <td class="editSyst emDetailsTable" >
                  System
                  </td>
                  <td class="editSyst emDetailsTable" >
                  <asp:TextBox ID="System" runat="server"
                  CssClass="input Box"></asp:TextBox>
                  </td>
                  </tr>
                  <tr>
                  <td class="editSyst emDetailsTable" CssClass="input Box">
                  Category
                  </td>
                  <td class="editSyst emDetailsTable" >
                  <asp:DropDownLi st ID="lstCategori es" runat="server">
                  </asp:DropDownLis t>
                  </td>
                  </tr>
                  <tr>
                  <td class="editSyst emDetailsTable" CssClass="input Box">
                  Importance
                  </td>
                  <td class="editSyst emDetailsTable" >
                  (Lowest)
                  <asp:RadioButto nList ID="RadioButton List1" runat="server"
                  RepeatDirection ="Horizontal ">
                  <asp:ListItem>1 </asp:ListItem>
                  <asp:ListItem>2 </asp:ListItem>
                  <asp:ListItem>3 </asp:ListItem>
                  </asp:RadioButton List>
                  (Highest)
                  </td>
                  </tr>
                  <tr>
                  <td class="editSyst emDetailsTable" >

                  </td>
                  <td class="editSyst emDetailsTable" >
                  <asp:Button ID="Save" runat="server" OnClick="Save_C lick"
                  Text="Save" CssClass="margi nLeft"
                  Style="text-align: center" />
                  </td>
                  </tr>
                  </table>
                  </fieldset>
                  <br />
                  <br />
                  <br />
                  <br />
                  </div>
                  </form>
                  </asp:Content>


                  --------------- EditSystem.aspx .cs ----------------

                  using System;
                  using System.Collecti ons;
                  using System.Configur ation;
                  using System.Data;
                  using System.Linq;
                  using System.Web;
                  using System.Web.Secu rity;
                  using System.Web.UI;
                  using System.Web.UI.H tmlControls;
                  using System.Web.UI.W ebControls;
                  using System.Web.UI.W ebControls.WebP arts;
                  using System.Xml.Linq ;

                  public partial class Admin_AddSystem : System.Web.UI.P age
                  {
                  private short srtSystemID;

                  protected void Page_Load(objec t sender, EventArgs e)
                  {

                  bool blnIsNewRecord = (Request.QueryS tring["id"] == null);

                  if (!blnIsNewRecor d)
                  { srtSystemID = Convert.ToInt16 (Request.QueryS tring["id"]); }


                  #region initialisation of page
                  if (!Page.IsPostBa ck)
                  {
                  if (!blnIsNewRecor d)
                  {
                  PopulateForm();

                  PopulateDropDow ns();
                  }
                  }

                  #endregion

                  }

                  protected void PopulateForm()
                  {
                  using (DataSet dsSystemDetails =
                  DAL.SystemStatu s.getSystemDeta ilsByID(srtSyst emID))
                  {
                  //Category.Text =
                  dsSystemDetails .Tables[0].Rows[0]["ss_categor y"].ToString();
                  //System.Text =
                  dsSystemDetails .Tables[0].Rows[0]["ss_system"].ToString();
                  //UnavailableFrom .Text =
                  dsSystemDetails .Tables[0].Rows[0]["ss_down_fr om"].ToString();
                  }
                  }

                  protected void PopulateDropDow ns()
                  {
                  using (DataSet dsCategories = DAL.SystemStatu s.getCategories ())
                  {
                  lstCategories.D ataSource = dsCategories;
                  lstCategories.D ataTextField = "ss_categor y";
                  lstCategories.D ataValueField = "ss_categor y";
                  lstCategories.D ataBind();
                  }
                  }


                  protected void Save_Click(obje ct sender, EventArgs e)
                  {

                  // save details of new system

                  //strSystem = System.Text;


                  // save details to database, and redirect to 'Maintain System
                  Details' page
                  //DAL.SystemStatu s.setSystemDeta ils(strSystem, strStatus,
                  datUnavailableF rom, datReavailableF rom, strReason, srtSystemID);

                  Response.Redire ct("ManageSyste ms.aspx");
                  }
                  }

                  --------------- default.master ----------------

                  <%@ Master Language="C#" AutoEventWireup ="true" CodeFile="defau lt.master.cs"
                  Inherits="maste r_default" %>

                  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
                  <html xmlns="http://www.w3.org/1999/xhtml">
                  <head runat="server">
                  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                  <title>
                  <asp:ContentPla ceHolder ID="htmlTitle" runat="server">
                  </asp:ContentPlac eHolder>
                  </title>
                  <link rel="stylesheet " type="text/css" href="/core/template/sidebar.css" />
                  <link rel="stylesheet " type="text/css"
                  href="/core/template/default_css.asp " />
                  <link rel="stylesheet " type="text/css" href="/core/template/screen.css"
                  media="screen" />
                  <link rel="stylesheet " type="text/css" href="/core/template/print.css"
                  media="print" />
                  <link rel="stylesheet " type="text/css" href="/core/template/sidebar.css" />
                  <link rel="stylesheet " type="text/css" href="~/StyleSheet.css" />
                  <!--[if IE]>
                  <link rel="stylesheet " type="text/css"
                  href="/core/template/default.ie.css"/>
                  <![endif]-->
                  <link rel="shortcut icon" href="/core/template/images/logo.dev.ico" />

                  <script language="javas cript" src="/core/punaAPI/punaAPI.js"
                  type="text/javascript"></script>

                  <asp:ContentPla ceHolder ID="head" runat="server">
                  </asp:ContentPlac eHolder>
                  </head>
                  <body>

                  <script type="text/javascript">

                  // some code removed

                  </script>

                  <!-- whole page container-->
                  <div id="container_p age">
                  <!-- main content wrapper (excludes footer) -->
                  <div id="container_c ontent">
                  <div id='container_m asthead'>
                  <!-- some code removed -->
                  </div>
                  <div id="navigation_ bar">
                  <div id="navigation" >
                  <ul id="nav">
                  <!-- add code similar to the following as the content of to the
                  dropDownMenus section, on each
                  individual page, and mark appropriate menu as being 'active' as
                  per the first <litag

                  <li id='active'><a href="/system_status/" title="Go to home
                  page" menu="home">Hom e</a></li>
                  <li><a href="#" menu="menu2">Dr op-down menu</a></li>
                  <li id="menu3"><a href="/system_status/help.aspx" title="Help
                  information" menu="help">Hel p</a></li>

                  *uses script that follows this general format, as included in
                  this master page:*

                  <script type="text/javascript">
                  // some code removed
                  </script>
                  -->
                  <asp:ContentPla ceHolder ID="dropDownMen us" runat="server">
                  </asp:ContentPlac eHolder>
                  </ul>
                  </div>
                  </div>
                  <!-- if breadcrumbs make sense in the application... -->
                  <asp:ContentPla ceHolder ID="breadcrumb " runat="server">
                  </asp:ContentPlac eHolder>
                  <!-- main content -->
                  <div id="container_t ext">
                  <!-- if the page title is to be highly visible to the end user... -->
                  <h2 id='pageTitle'>
                  </h2>
                  <asp:ContentPla ceHolder ID="main" runat="server">
                  </asp:ContentPlac eHolder>
                  </div>
                  <!-- end main content -->
                  </div>
                  <!-- end main content wrapper -->
                  <!-- footer content -->
                  <!-- end footer content -->
                  </div>
                  <!-- end whole page container -->
                  </form>
                  </body>
                  </html>



                  --------------- default.master. cs ----------------

                  using System;
                  using System.Collecti ons;
                  using System.Configur ation;
                  using System.Data;
                  using System.Linq;
                  using System.Web;
                  using System.Web.Secu rity;
                  using System.Web.UI;
                  using System.Web.UI.W ebControls;
                  using System.Web.UI.W ebControls.WebP arts;
                  using System.Web.UI.H tmlControls;
                  using System.Xml.Linq ;

                  public partial class master_default : System.Web.UI.M asterPage
                  {
                  protected void Page_Load(objec t sender, EventArgs e)
                  {


                  }

                  }

                  ----------------


                  "Gaurav Vaish (a.k.a. MasterGaurav)" wrote:
                  Thanks for the very quick reply. You're right that I'm using .NET 3.5.
                  Unfortunately, your suggestion is not the cause of the problem - I'm not
                  trying to set a property 'Web' equal to anything in code. The class in
                  the
                  code behind is defined as:

                  public partial class RecordDetails : System.Web.UI.P age
                  >
                  Can you please post across both the files - aspx and code-beside?
                  >
                  Or if it's too public a forum... mail at gaurav[~dot~]vaish[~at~]gmail.
                  >
                  >
                  >
                  --
                  Happy Hacking,
                  Gaurav Vaish | http://dwt.sourceforge.net
                  http://blogs.mastergaurav.com | http://eduzine.edujini-labs.com
                  --------------------------------
                  >
                  >
                  >
                  >
                  >

                  Comment

                  Working...