Question: I want to develop a simple web part using VS 2012 and add this code for button click:

```
SPListItem Item = SPContext.Current.Web.Lists["Tasks"].Items.Add();
Item["Title"] = TextBox1.Text;
Item["Due Date"] = Calendar1.SelectedDate;
Item.Update();
Label1.Text = "Item Added";
TextBox1.Text = "";

ScriptManager.RegisterStartupScript(this, GetType(), 'nima', "alert('this is nima');",true);

```

but the problem is this alert does not show and this code does not render in my page.

How I can inject javascript to a page in Sharepoint 2010?

thanks

Answer: 
try once using ClientScript.RegisterStartupScript as below :

```
Page.ClientScript.RegisterStartupScript(this.GetType(), "nima", "alert('this is nima');", true);

```
I would lean towards throwing the JS into a literal object on the page, as I have found this is 1) easier and 2) give you a wee bit more control on what is really going on. So instead of using the ScriptManager, throw your script 

```
<script type="text/javascript">
$(document).ready(function() {
   alert("this is nima");
});
</script>

```

in a ASP:Literal control.