Error: Ambiguous Server Tag

Sometimes I run into this error when using ASP.NET:

“The server tag ‘asp:ScriptManager’ is ambiguous. Please modify the associated registration that is causing ambiguity and pick a new tag prefix.”

Usually, this occurs because I am having a conflict between different versions of System.Web.Extensions.

For example, in my web.config I have the reference to the 3.5 version:

<add tagPrefix=asp namespace=System.Web.UI assembly=System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35/>

But in my .aspx page I have a reference to the 1.0 version:

<%@ Register Assembly=”System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ Namespace=”System.Web.UI” TagPrefix=”asp” %>

Solution: Remove “Register Assembly” from .aspx and the asp tagPrefix should now use the web.config version and correctly reference, in this case, AJAX 3.5.

Create Graph Data Using A Two-Dimensional Array

In this example, I am using a two-dimensional array to provide attributes for a graph from Fusion Charts :

/*Store sales data*/
string[,] arrData = new string[4, 2];

arrData[0, 1] = “Annual Cash Compensation”;

arrData[1, 1] = “Annual LTI Compensation”;

arrData[2, 1] = “Current Financial Protection”;

arrData[3, 1] = “Future Financial Security”;

/*Store sales amounts*/

arrData[0, 2] = PercentDC.ToString();

arrData[1, 2] = PercentLT.ToString();

arrData[2, 2] = PercentCFP.ToString();

arrData[3, 2] = PercentFFS.ToString();

/*Now, we need to convert this data into XML. We convert using
string concatenation.*/

string strXML = “”;

/*Convert data to XML and append*/
for(int pieI = 0; pieI <= arrData.Length - 1; pieI++)
{ strXML = strXML & ““; }

Save Dataset To Comma-Delimited File

//save dataset to file

private void saveFile()

{

try

{

saveFileDialog1.Filter = “Text File|*.csv”;

DialogResult dr = saveFileDialog1.ShowDialog();

if (dr.Equals(DialogResult.OK))

{

Stream saveStream = saveFileDialog1.OpenFile();

StreamWriter saveWriter = new StreamWriter(saveStream);

string delim = “”;

foreach (DataColumn c in usmDataSet_LocateEst.qLocateEst.Columns)

{

saveWriter.Write(delim);

saveWriter.Write(c.ColumnName);

delim = “,”;

}

saveWriter.WriteLine();

foreach (DataRow r in usmDataSet_LocateEst.qLocateEst.Rows)

{

delim = “”;

foreach (DataColumn c in usmDataSet_LocateEst.qLocateEst.Columns)

{

saveWriter.Write(delim);

saveWriter.Write(r[c]);

delim = “,”;

}

saveWriter.WriteLine();

}

saveWriter.Close();

MessageBox.Show(“File Saved!”, “Save Results”, MessageBoxButtons.OK, MessageBoxIcon.Information);

}

}

catch (Exception ex)

{

MessageBox.Show(“Error Saving File: “ + ex.Message, “Error!”, MessageBoxButtons.OK, MessageBoxIcon.Error);

}

}