473,473 Members | 1,733 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

.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:RequiredFieldValidator ...), 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.TextBox' does not contain a definition
for 'Web' and no extension method 'Web' accepting a first argument of type
'System.Web.UI.WebControls.TextBox' could be found (are you missing a using
directive or an assembly reference?)

I had the same error when I tried to get a 'CompareValidator' 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.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

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 :)
Jul 22 '08 #1
8 8913
CS1061: 'System.Web.UI.WebControls.TextBox' does not contain a definition
for 'Web' and no extension method 'Web' accepting a first argument of type
'System.Web.UI.WebControls.TextBox' 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
http://blogs.mastergaurav.com
http://eduzine.edujini-labs.com
---------------------------
Jul 23 '08 #2
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.Page

I think that this means that the partial class inherits from
System.Web.UI.Page? 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="ReavailableFrom" runat="server"
CssClass="inputBox"></asp:TextBox>
<asp:RequiredFieldValidator
ID="ReavailableFromRequiredValidator" runat="server"
ErrorMessage="You must enter an estimate for 'Unavailable
To'" ControlToValidate="ReavailableFrom"
Style="margin-left: 15px"
EnableClientScript="False"></asp:RequiredFieldValidator>
<asp:CompareValidator ID="ReavailableFromCompareValidator"
ControlToCompare="UnavailableFrom" runat="server"
ErrorMessage="CompareValidator" Operator="GreaterThan"
Type="Date"></asp:CompareValidator>

As I've mentioned, the RequiredFieldValidator on its own works, but as soon
as I add the code for the CompareValidator 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.TextBox' does not contain a definition
for 'Web' and no extension method 'Web' accepting a first argument of type
'System.Web.UI.WebControls.TextBox' 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
http://blogs.mastergaurav.com
http://eduzine.edujini-labs.com
---------------------------
Jul 24 '08 #3
On Thu, 24 Jul 2008 16:26:01 -0700, Chris Halcrow
<Ch**********@discussions.microsoft.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.Page

I think that this means that the partial class inherits from
System.Web.UI.Page? 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
Jul 24 '08 #4
On Thu, 24 Jul 2008 16:26:01 -0700, Chris Halcrow
<Ch**********@discussions.microsoft.comwrote:
[...]
<asp:CompareValidator ID="ReavailableFromCompareValidator"
ControlToCompare="UnavailableFrom" runat="server"
ErrorMessage="CompareValidator" Operator="GreaterThan"
Type="Date"></asp:CompareValidator>

As I've mentioned, the RequiredFieldValidator on its own works, but as
soon
as I add the code for the CompareValidator 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
CompareValidator includes a "ControlToValidate" 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
Jul 24 '08 #5
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 "ControlToValidate" property is unrelated to
this issue

Thanks again, Chris

"Peter Duniho" wrote:
On Thu, 24 Jul 2008 16:26:01 -0700, Chris Halcrow
<Ch**********@discussions.microsoft.comwrote:
[...]
<asp:CompareValidator ID="ReavailableFromCompareValidator"
ControlToCompare="UnavailableFrom" runat="server"
ErrorMessage="CompareValidator" Operator="GreaterThan"
Type="Date"></asp:CompareValidator>

As I've mentioned, the RequiredFieldValidator on its own works, but as
soon
as I add the code for the CompareValidator 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
CompareValidator includes a "ControlToValidate" 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
Jul 25 '08 #6
On Thu, 24 Jul 2008 17:42:03 -0700, Chris Halcrow
<Ch**********@discussions.microsoft.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
Jul 25 '08 #7
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.Page
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
--------------------------------


Jul 27 '08 #8
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.TextBox' 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="EditSystem.aspx.cs" Inherits="Admin_AddSystem" Title="Untitled
Page" %>

<asp:Content ID="htmlTitle" ContentPlaceHolderID="htmlTitle" runat="Server">
IST Systems Status - Edit System
</asp:Content>
<asp:Content ID="head" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="dropDownMenus" ContentPlaceHolderID="dropDownMenus"
runat="Server">
<li><a href="/system_status/" title="Go to home page"
menu="home">Home</a></li>
<!--<li><a href="#" menu="menu2">Drop-down menu</a></li>-->
<li id="active"><a href="/system_status/Admin/ManageStatus.aspx"
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" ContentPlaceHolderID="breadcrumb" runat="Server">
<div class="breadcrumb">
<a href=''>IST</a/ <a href="/system_status/">
System Status</a/ Update Systems / <a
href="/system_status/Admin/ManageSystems.aspx">
Manage Systems</a/ Edit System
</div>
</asp:Content>
<asp:Content ID="main" ContentPlaceHolderID="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="editSystemDetailsTable">
<tr>
<td class="editSystemDetailsTable">
System
</td>
<td class="editSystemDetailsTable">
<asp:TextBox ID="System" runat="server"
CssClass="inputBox"></asp:TextBox>
</td>
</tr>
<tr>
<td class="editSystemDetailsTable" CssClass="inputBox">
Category
</td>
<td class="editSystemDetailsTable">
<asp:DropDownList ID="lstCategories" runat="server">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="editSystemDetailsTable" CssClass="inputBox">
Importance
</td>
<td class="editSystemDetailsTable">
(Lowest)
<asp:RadioButtonList ID="RadioButtonList1" runat="server"
RepeatDirection="Horizontal">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp:RadioButtonList>
(Highest)
</td>
</tr>
<tr>
<td class="editSystemDetailsTable">

</td>
<td class="editSystemDetailsTable">
<asp:Button ID="Save" runat="server" OnClick="Save_Click"
Text="Save" CssClass="marginLeft"
Style="text-align: center" />
</td>
</tr>
</table>
</fieldset>
<br />
<br />
<br />
<br />
</div>
</form>
</asp:Content>
--------------- EditSystem.aspx.cs ----------------

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

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

protected void Page_Load(object sender, EventArgs e)
{

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

if (!blnIsNewRecord)
{ srtSystemID = Convert.ToInt16(Request.QueryString["id"]); }
#region initialisation of page
if (!Page.IsPostBack)
{
if (!blnIsNewRecord)
{
PopulateForm();

PopulateDropDowns();
}
}

#endregion

}

protected void PopulateForm()
{
using (DataSet dsSystemDetails =
DAL.SystemStatus.getSystemDetailsByID(srtSystemID) )
{
//Category.Text =
dsSystemDetails.Tables[0].Rows[0]["ss_category"].ToString();
//System.Text =
dsSystemDetails.Tables[0].Rows[0]["ss_system"].ToString();
//UnavailableFrom.Text =
dsSystemDetails.Tables[0].Rows[0]["ss_down_from"].ToString();
}
}

protected void PopulateDropDowns()
{
using (DataSet dsCategories = DAL.SystemStatus.getCategories())
{
lstCategories.DataSource = dsCategories;
lstCategories.DataTextField = "ss_category";
lstCategories.DataValueField = "ss_category";
lstCategories.DataBind();
}
}
protected void Save_Click(object sender, EventArgs e)
{

// save details of new system

//strSystem = System.Text;
// save details to database, and redirect to 'Maintain System
Details' page
//DAL.SystemStatus.setSystemDetails(strSystem, strStatus,
datUnavailableFrom, datReavailableFrom, strReason, srtSystemID);

Response.Redirect("ManageSystems.aspx");
}
}

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

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="default.master.cs"
Inherits="master_default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
<asp:ContentPlaceHolder ID="htmlTitle" runat="server">
</asp:ContentPlaceHolder>
</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="javascript" src="/core/punaAPI/punaAPI.js"
type="text/javascript"></script>

<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>

<script type="text/javascript">

// some code removed

</script>

<!-- whole page container-->
<div id="container_page">
<!-- main content wrapper (excludes footer) -->
<div id="container_content">
<div id='container_masthead'>
<!-- 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">Home</a></li>
<li><a href="#" menu="menu2">Drop-down menu</a></li>
<li id="menu3"><a href="/system_status/help.aspx" title="Help
information" menu="help">Help</a></li>

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

<script type="text/javascript">
// some code removed
</script>
-->
<asp:ContentPlaceHolder ID="dropDownMenus" runat="server">
</asp:ContentPlaceHolder>
</ul>
</div>
</div>
<!-- if breadcrumbs make sense in the application... -->
<asp:ContentPlaceHolder ID="breadcrumb" runat="server">
</asp:ContentPlaceHolder>
<!-- main content -->
<div id="container_text">
<!-- if the page title is to be highly visible to the end user... -->
<h2 id='pageTitle'>
</h2>
<asp:ContentPlaceHolder ID="main" runat="server">
</asp:ContentPlaceHolder>
</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.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;

public partial class master_default : System.Web.UI.MasterPage
{
protected void Page_Load(object 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.Page

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
--------------------------------


Jul 28 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Juma | last post by:
Hi, I have an have an application at a production server that is running on the .NET Framework 1.1.The version which I used while developing the application was 1.0. For some reason the...
7
by: Paul | last post by:
Hi, I have a form where a user is required to enter a start date and an end date. Both are required and must between a specific date range (e.g. 01/01/1900 and 01/01/2099) and the end date...
14
by: Matt | last post by:
I want to know if ASP.NET Web Forms Validation Controls are Server-Side or Client-Side form validation? Since I think each validator control can select either 1) JavaScript based error dialog or 2)...
1
by: dhurwitz | last post by:
Hi I have developed a web app with a dozen or so pages, which allows searching for and editing orders by OrderID. There is a search page for entering multiple search criteria. In addition, each...
2
by: Martyn Fewtrell | last post by:
Dear All I have a Windows 2003 Server with IIS6 where the validation controls on ASP.Net pages no longer work. I believe it to be specific to the server as if I create an ASP.Net page on the...
0
by: aeshtry | last post by:
Hello dear friends I have an urgent question. Would you please give me your professional idea? I have an html table containing the ASP.Net validation summary and an ASP.Net label control. The...
2
by: rodchar | last post by:
hey all, can the validation controls popup an alert window if triggered? thanks, rodchar
1
by: nRk | last post by:
Hi, I am working on asp.net 2.0 with Visual Studio 2005. My asp.net project contains one Masterpage. I exposed my asp.net project in my machine (Windows XP with IIS 5.1) and access using...
2
by: m.a | last post by:
Hello, I have the following code which is an entity for a table in my database. but I am getting several errors such as: The type or namespace name 'ColumnAttribute' could not be found (are...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.