For example, that first Response.Write can be replaced with a ClientScript.RegisterStartupScript which is cleaner.