Hi,
The "Ambiguous match found" error is the most annoying error I faced ever. This can occur when more than one component in the the aspx/ascx file have same name.
For example, here's what I have in default.aspx page.
And Here's my code in default.aspx.cs.
In this case, though the code compiles, we get a run time error saying that "Ambiguous match found". This is because we have a label called "Label1" and a string in .cs file with name "label1".
So, next time you get this issue, make sure that all elements in your solution have unique ID's :)
Happy Coding !!!
The "Ambiguous match found" error is the most annoying error I faced ever. This can occur when more than one component in the the aspx/ascx file have same name.
For example, here's what I have in default.aspx page.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication._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"> <title></title> </head> <body> <form id="form1" runat="server"> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> </form> </body> </html>
And Here's my code in default.aspx.cs.
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Globalization; using System.Text; using System.Data; using System.Drawing; namespace WebApplication { public partial class _Default : System.Web.UI.Page { string label1 = string.Empty; protected void Page_Load(object sender, EventArgs e) { } } }
In this case, though the code compiles, we get a run time error saying that "Ambiguous match found". This is because we have a label called "Label1" and a string in .cs file with name "label1".
So, next time you get this issue, make sure that all elements in your solution have unique ID's :)
Happy Coding !!!
No comments:
Post a Comment