Attempting to dynamically generate a javascript function call and pass a string
<p>I have a data source that I <strong>can not alter</strong>, the data source contains a hyperlink with an Id in it that I can use to retrieve data that I need. I created a method to convert the hyperlink to call a javascript function and pass the scrubbed id from the hyperlink, however I am not getting the correct results. In its current state everything is working except the insertion of the id var into the ClickIt method. For this example the value of id is djb137, and when I click on the new hyperlink the error returned is 'djb137 is undefined. Am I overlooking something on passing a paramater to a javascript function?</p>

<pre><code>private string ScrubHref(string statementHtml)
    {
        string pattern = "href.*?\"(?&lt;href&gt;.*?)\"";

        return Regex.Replace(statementHtml, pattern, delegate(Match match)
        {
            string v = match.ToString();

            string id = Regex.Match(v, "\"([^\"]*?)\"").Groups[1].Value;

            string returnValue = "href=\"#\"" + "onclick=\"return ClickIt("+id+");\"";

            return returnValue;
        });
    }
</code></pre>

<p>Intrestingly If I change the retrunValue string to this</p>

<pre><code>return v + "onclick=\"return ClickIt(this.href);\"";
</code></pre>

<p>Then my javascript function gets the whole href passed to it without issue.But I just need the Id not the whole href.</p>
