Ramakrishna
Ramakrishna

Reputation: 83

how to avoid this error

In my page, if i refer using System.windows.forms; using System.web.webcontrols.....

Textbox ambiguos refernece error is occured from webcontrols and forms,

how can i rectify this error... but i need those two namespaces in my asp.net page.

Upvotes: 1

Views: 933

Answers (3)

Jakob Christensen
Jakob Christensen

Reputation: 14956

Let me first say that I find it a bit odd that you need to reference System.Windows.Forms in an ASP.NET project.

As already posted by ondesertverge, you can fully qualify your types. You can create aliases for the namespaces to save some typing:

using WebForms = System.Web.WebControls;
using WinForms = System.Windows.Forms;

// ...

var textbox = new WebForms.TextBox();

Upvotes: 1

Oded
Oded

Reputation: 499262

You can alias the namespaces and uses the alias for each type:

using winforms = System.Windows.Forms;
using webForms = System.Web.Webcontrols;
...

     winforms::TextBox ...
     webforms::TextBox ...

...

Another option is to use the full name for each type (including the namespace), to avoid ambiguity.

Upvotes: 0

David Perlman
David Perlman

Reputation: 1470

You can fully qualify one of them.

System.Windows.Forms.TextBox

Upvotes: 0

Related Questions