Fig - (1) Code behind file Default.aspx.cs
Fig - (2) Default.aspx page
Now when you run this page the output will be,
Fig - (3) Output of the Default.aspx page
You can see that the script we have register using RegisterStartupScriptBlock renders first and the statement document.write writes "RegisterClientScriptBlock" to the page then we have the Page Content and finally the "StartupScriptRegistered". If you see the view source,
Fig - (4) View Source for Default.aspx
As you can see at lines 14 to 17 we have the script registered using "RegisterStartupScript" and at lines 32 to 35 we have the script registered using "RegisterStartupScript".
Now you can easily identify when you have to use RegisterStartupScript and when to use RegisterClientScriptBlock. If you want to assign any value or property or want to get the value or property from any element you should use RegisterStartupScript. If you use RegisterClientScriptBlock you will get error object undefined as the particular object is not being rendered yet.
Happy Programming !!!