Unterminated string constant error when passing sitename to the javascript function
<p>when user clicks on the Edit button on the grid I am passing sitename and order id(hidden value) to the javascript function. I am getting "Unterminated string constant error" for one sitename. I dont know whats wrong in that. Please see the Image below.<img src="http://i.stack.imgur.com/D6zww.jpg" alt="enter image description here"></p>

<pre><code>protected void gvCktMap_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        try
        {
            if (Session["TaskID"] != null)
            {
                int intTskID = Convert.ToInt32(Session["TaskID"]);
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    e.Row.Attributes.Add("class", "taskListRow");
                }
                CheckBox chkBoxOne = (CheckBox)e.Row.FindControl("chkSelect");
                Label lblREJ = (Label)e.Row.FindControl("lblREJ");
                // Label lblDesc = (Label)e.Row.FindControl("lblDesc");
                Label lblStatus = (Label)e.Row.FindControl("lblTaskStatus");
                Label lblDaysUntillPTD = (Label)e.Row.FindControl("lblDaysUntilPTD");
                Label lblPastDue = (Label)e.Row.FindControl("lblPastDue");
                if (lblStatus != null)
                {
                    if (lblStatus.Text.Trim().ToLower() == "complete" || lblStatus.Text.Trim().ToLower() == "not_required")
                        chkBoxOne.Enabled = false;
                }
                //Do Not move this code...We are selecting orderids based on checkbox enable or not....//Babu//
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    LinkButton lnkSiteName = (LinkButton)e.Row.FindControl("lnkSiteName");
                    Label lblServiceOrderNumber = (Label)e.Row.FindControl("lblServiceOrderNumber");
                    LinkButton lnkCMNumber = (LinkButton)e.Row.FindControl("lnkCORECMNumber");
                    LinkButton lnkSiteCMTicketNumber = (LinkButton)e.Row.FindControl("lnkSiteCMTicketNumber");
                    LinkButton lnkSMNumber = (LinkButton)e.Row.FindControl("lnkSMTicketNumber");
                    LinkButton lnkSiteSMTicketNumber = (LinkButton)e.Row.FindControl("lnkSiteSMTicketNumber");
                    Label lblorderId = (Label)e.Row.FindControl("lblorderId");
                    Label lblsId = (Label)e.Row.FindControl("lblsId");
                    Label lblsiteId = (Label)e.Row.FindControl("lblsiteId");
                    Label lbllob = (Label)e.Row.FindControl("lblLOB");
                    Label lblclarifyAccountNumber = (Label)e.Row.FindControl("lblclarifyAccountNumber");
                    Label lblTaskStatus = (Label)e.Row.FindControl("lblTaskStatus");
                    LinkButton lnkCustomerName = (LinkButton)e.Row.FindControl("lnkCustomerName");
                    LinkButton lnkProjectName = (LinkButton)e.Row.FindControl("lnkProjectName");
                    LinkButton lnkRoeID = (LinkButton)e.Row.FindControl("lnkPreSaleAssociation");
                    ImageButton detailsbutton = (ImageButton)e.Row.FindControl("btnDetails");
                    LinkButton lnkpendingdependencies = (LinkButton)e.Row.FindControl("lnkPendingDependencies");
                    LinkButton lnknotes = (LinkButton)e.Row.FindControl("lnkNotes");
                    LinkButton lnkuserpendingdependencies = (LinkButton)e.Row.FindControl("lnkUserPendingDependences");
                    LinkButton lnkPendJeopCount = (LinkButton)e.Row.FindControl("lnkPendJeopCount");
                    LinkButton lnkPreSaleAssociation = (LinkButton)e.Row.FindControl("lnkPreSaleAssocation");
                    LinkButton lnktaskowner = (LinkButton)e.Row.FindControl("lnkTaskOwner");
                    LinkButton lnkConfigs = (LinkButton)e.Row.FindControl("lnkConfigFiles?");
                    LinkButton lnkCircuits = (LinkButton)e.Row.FindControl("lnkCircuits");
                    LinkButton lnkOptics = (LinkButton)e.Row.FindControl("lnkOptics");
                    ImageButton btnMixedorder = (ImageButton)e.Row.FindControl("btnMixedOrd");
                    ImageButton edit_button = (ImageButton)e.Row.FindControl("edit_button");
                    if (edit_button != null)
                        edit_button.OnClientClick = "StoreOrderIDAndLOB('" + lblorderId.Text + "','" + lbllob.Text + "')";

                    if (lnkConfigs != null)
                        lnkConfigs.OnClientClick = "StoreConfigs('" + lblsId.Text + "','" + lnkSiteName.Text.Replace("'", "&amp;apos") + "')";

                    if (lnktaskowner != null)
                        lnktaskowner.OnClientClick = "StoreTaskOwner('" + lnkSiteName.Text.Replace("'", "&amp;apos") + "','" + lnktaskowner.Text.Replace("'", "&amp;apos") + "','" + lblorderId.Text + "','" + lbllob.Text + "','" + lblTaskStatus.Text + "')";

                    if (lnkSiteName != null)
                        lnkSiteName.OnClientClick = "StoreLnkSiteName('" + lblorderId.Text + "','" + lnkSiteName.Text.Replace("'", "&amp;apos") + "')";

                    if (detailsbutton != null)
                        detailsbutton.OnClientClick = "Storedetails('" + lnkSiteName.Text.Replace("'", "&amp;apos") + "')";

                    if (lnkCMNumber != null)
                        lnkCMNumber.OnClientClick = "StoreCMNumber('" + lnkCMNumber.Text + "', '" + lblorderId.Text + "')";

                    if (lnkSiteCMTicketNumber != null)
                        lnkSiteCMTicketNumber.OnClientClick = "StoreSiteCMTicketNumber('" + lnkSiteCMTicketNumber.Text + "', '" + lblorderId.Text + "')";

                    if (lnkSMNumber != null)
                        lnkSMNumber.OnClientClick = "StorelnkSMNumber('" + lnkSMNumber.Text + "', '" + lblorderId.Text + "')";

                    if (lnkSiteSMTicketNumber != null)
                    {
                        lnkSiteSMTicketNumber.OnClientClick = "StorelnkSiteSMTicketNumber('" + lnkSiteSMTicketNumber.Text + "', '" + lblorderId.Text + "')";
                    }
                    if (lnkpendingdependencies != null)
                    {
                        lnkpendingdependencies.OnClientClick = "StoreOrderId('" + lblorderId.Text + "')";
                    }
                    if (lnknotes != null)
                    {
                        lnknotes.OnClientClick = "StoreNotes('" + lblorderId.Text + "','" + lnkSiteName.Text.Replace("'", "&amp;apos") + "')";
                    }
                    if (lnkuserpendingdependencies != null)
                    {
                        lnkuserpendingdependencies.OnClientClick = "StoreUserpendingdependencies('" + lblorderId.Text + "','" + lnkSiteName.Text.Replace("'", "&amp;apos") + "')";
                    }
                    if (lnkPendJeopCount != null)
                    {
                        lnkPendJeopCount.OnClientClick = "StorePendJeopCount('" + lblorderId.Text + "','" + lnkSiteName.Text.Replace("'", "&amp;apos") + "')";
                    }
                    if (lnkProjectName != null)
                    {
                        lnkProjectName.OnClientClick = "Storeprojectname('" + lnkProjectName.Text.Replace("'", "&amp;apos") + "')";
                    }
                    if (lnkCustomerName != null)
                    {
                        lnkCustomerName.OnClientClick = "StoreCustomername('" + lnkCustomerName.Text.Replace("'", "&amp;apos") + "')";
                    }
                    if (lnkPreSaleAssociation != null)
                    {
                        lnkPreSaleAssociation.OnClientClick = "StorePreSaleAssociation('" + lblorderId.Text.Trim() + "','" + lblsId.Text.Trim() + "','" + lblTaskStatus.Text.Trim() + "')";
                    }
                    if (lnkCircuits != null)
                    {
                        lnkCircuits.OnClientClick = "StoreCircuitsInfo('" + lblorderId.Text + "','" + lblsiteId.Text + "','" + lbllob.Text + "','" + lblclarifyAccountNumber.Text + "','" + lnkSiteName.Text.Replace("'", "&amp;apos") + "')";
                    }
                    if (lnkOptics != null)
                    {
                        lnkOptics.OnClientClick = "StoreOpticsInfo('" + lblsId.Text + "','" + lnkSiteName.Text.Replace("'", "&amp;apos") + "')";
                    }
                    if (btnMixedorder != null)
                    {
                        btnMixedorder.OnClientClick = "StoreMixedorder('" + lblServiceOrderNumber.Text + "')";
                    }
                }
            }
        }
        catch (Exception ex)
        {
            log4net.Config.XmlConfigurator.Configure();
            log.Warn("Logging:" + ex);
        }
    }
</code></pre>

<p>How to resolve this error?</p>

<pre><code>function StoreOrderIDAndLOB(sender) {
//get handle to parent row:
var oRow = sender;
while (oRow &amp;&amp; oRow.tagName.toLowerCase() !== "tr")
    oRow = oRow.parentNode;

//something might be wrong, sanity check:
if (!oRow)
    return;

//build array of all possible elements we have to look into:
var elements = [];
var arrSpans = oRow.getElementsByTagName("span");
for (var i = 0; i &lt; arrSpans.length; i++)
    elements.push(arrSpans[i]);

//site name is the sender, grab its contents:
var siteName = "";
for (var i = 0; i &lt; elements.length; i++) {
    var element = elements[i];
    if (element.id.indexOf("lnkSiteName") &gt;= 0) {
        siteName = element.innerHTML;
        break;
    }
}
siteName = sender.innerHTML;

//find the order ID by looking for matching element:
var orderId = "";
for (var i = 0; i &lt; elements.length; i++) {
    var element = elements[i];
    if (element.id.indexOf("lblorderId") &gt;= 0) {
        orderId = element.innerHTML;
        break;
    }
}

//here you can use the values same way you use in the original code...
alert("site name: " + siteName + " and order ID is " + orderId);
</code></pre>

<p>}</p>
