I have an ASP.NET web application and at a certain point I do this:
mycontrol.stringparameterforjscript = \"document.getElementById(\'\" + myotherparam + \"\').v
I think you might need the @ on both string literals in your assignment, and remove the slashes:
mycontrol.stringparameterforjscript = @"document.getElementById('" + myotherparam + @"').value = 'Hello'";
EDIT
How I did it:
On the .aspx:
In the code:
protected void Page_Load(object sender, EventArgs e)
{
string myotherparam = "paramval";
tbTest.Attributes.Add("onfocus", @"document.getElementById('" + myotherparam + @"').value = 'Hello'");
}
Resultant output: