System.ArgumentException: Item has already been added. Key in dictionary: 'language' Key being added: 'language' at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)

I have a web application in which I have a grid view.
Whenever I try to perform delete/ add/ modify operation on the grid view on a button click, I get following error:

2       System.ArgumentException: Item has already been added. Key in dictionary: 'language' Key being added: 'language'
3       at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)
4       at System.Collections.Hashtable.Add(Object key, Object value)
5       at System.Collections.Specialized.OrderedDictionary.Add(Object key, Object value)
6       at System.Web.UI.ScriptRegistrationManager.WriteScriptWithTags(HtmlTextWriter writer, String token, RegisteredScript        activeRegistration)
7       at System.Web.UI.ScriptRegistrationManager.RenderActiveScriptBlocks(List`1 updatePanels, HtmlTextWriter writer, String token,        List`1 scriptRegistrations)
8       at System.Web.UI.ScriptRegistrationManager.RenderActiveScripts(List`1 updatePanels, HtmlTextWriter writer)
9       at System.Web.UI.PageRequestManager.ProcessScriptRegistration(HtmlTextWriter writer)
10       at System.Web.UI.PageRequestManager.RenderPageCallback(HtmlTextWriter writer, Control pageControl)
11       at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
12       at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
13       at System.Web.UI.Page.Render(HtmlTextWriter writer)
14       at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
15       at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
16       at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
17       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Please see the attachments for the .aspx and .aspx.cs code

please help! Course-Schedule-aspx.txt Course-Schedule-aspx-cs.txt
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Could you try to give unique Id while registering the script through Scriptmanager

ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "script1"

some of the Id's are repeated in more than one place
Tina_BholeAuthor Commented:
Hi santhimurthyd,

Thanks for your response.
I tried giving unique ids to the script blocks. It didn't help.
The only possible cause I can see is at line 154, where you have two attributes called "language"

GlobalClass.JScript_Alert = @"<script language='javascript' language='javascript'

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
In addition to that the alert message with Javascript are not enclosed

Your syntax
GlobalClass.JScript_Alert = @"<script language='javascript'>alert(" + exp.ToString() + ");</script>";

Have to be
GlobalClass.JScript_Alert = @"<script language='javascript'>alert('" + exp.ToString() + "');</script>";

Some more places, you need to consider he above syntax like

In yours
e.Row.Attributes["onclick"] = "CourseScheduleGV_selectRow(this," + e.Row.RowIndex + ");";

have to be
e.Row.Attributes["onclick"] = "CourseScheduleGV_selectRow(this,'" + e.Row.RowIndex + "');

In the Method
protected void SaveRecord(object sender, EventArgs e)

As mentioned by sybe
there are couple of syntax with dual entry for  language='javascript'

GlobalClass.JScript_Alert = @"<script language='javascript' language='javascript' type='text/javascript'>alert('Please Enter the Course Schedule Details.');</script>";

GlobalClass.JScript_Alert = @"<script language='javascript' language='javascript' type='text/javascript'>alert('Course End Date cannot be greater than Course Start Date');</script>";

lobalClass.JScript_Alert = @"<script language='javascript' language='javascript' type='text/javascript'>alert('Course End Date cannot be greater than Course Start Date');</script>";

please let you outcoem after the above changes

Tina_BholeAuthor Commented:
Thanks for helping Santhimurthyd and sybe.
Yes, making use of language='javascript' was itself a big mistake I made because the language attribute has been deprecated. I used type='text/javascript' instead of language.

@ santhimurthyd : the application is working perfectly fine without changing
"CourseScheduleGV_selectRow(this," + e.Row.RowIndex + ");";
"CourseScheduleGV_selectRow(this,'" + e.Row.RowIndex + "');
So, for the time being, I have left it as it is.

Thanks a lot once again.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.