In my .aspx page I am using a <span id="showMessage">and <asp:button>. When you will click the <asp:button>, focus will go to the server side then there I have written my code that will alert a message and display my name in the <span id="showMessage">. Let’s have a look over how to do so
Page.RegisterStartupScript automatically attach the script just before the closing tag of your aspx page object’s <form runat="server">
Page.RegisterStartupScript method uses a unique key to identify the script block; the script block does not have to be emitted to the output stream every time it is requested by a different server control instance.