Click here to Skip to main content
15,893,814 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
string Result=rptColumnBAL.CheckDuplicateColumnsBAL(calcDetail);
           if (Result == calcDetail.DisplayColumnName)
           {
               Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script language='javascript' type='text/javascript'>alert('The column name you have chosen is already in use. Please enter a different name')</script>");
           }

           else if (Result == "")
           {
               Session["CalcFormula"] = calcDetail.calculationFormula;
               Session["DisplayColumnName"] = calcDetail.DisplayColumnName;
               Session["UseDividendIfZero"] = (cbDividend.Checked == true ? true : false);
               Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "CloseWin", "<script language='javascript'>close();</script>");
           }
          else
           {

               Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script language='javascript' type='text/javascript'>alert('The formula you created already exists under the column name:'" + Result + ")</script>");
           }
Posted

1 solution

Try this, give your scripts unique keys and let the framework wrap it in script tags for you.

C#
string Result=rptColumnBAL.CheckDuplicateColumnsBAL(calcDetail);
           if (Result == calcDetail.DisplayColumnName)
           {
               Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alertInvalidColName", "alert('The column name you have chosen is already in use. Please enter a different name');", true);
           }
 
           else if (Result == "")
           {
               Session["CalcFormula"] = calcDetail.calculationFormula;
               Session["DisplayColumnName"] = calcDetail.DisplayColumnName;
               Session["UseDividendIfZero"] = (cbDividend.Checked == true ? true : false);
               Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "CloseWin", "close();", true);
           }
          else
           {
 
               Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alertInvalidFormula", "alert('The formula you created already exists under the column name: " + Result + "');", true);
           };


Also you had single quotes all over the place so chances are your script was being rendered but just causing errors when it ran.
 
Share this answer
 
Comments
Member 9581488 17-Dec-12 11:48am    
thank you! that worked....Do have one problem. when i see alert msg data on the page disappears.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900