Is it OK to generate code like this on the fly? Or is this a major code smell? How can this be made better?
I'm new to web but I'm stumbling across this all the time and I don't really understand why.
// Create a js function that applies foo to each group of controls
foreach (KeyValuePair<string, Dictionary<Control, string>> pair in maps)
{
js.Append(pair.Key);
js.Append("=function(grid){Prm.remove_endRequest(");
js.Append(pair.Key);
js.Append(");if(grid && grid._element)"); // ... blah blah blah
}
page.ClientScript.RegisterClientScriptBlock(page.GetType(), key + "Ajax",
js.ToString(), true);