No,It is not mandatory unitl you get response from server side method.you refer below code.
HTML
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
</asp:ScriptManager>
<script type="text/javascript">
function ShowCurrentTime() {
PageMethods.GetCurrentTime(document.getElementById("<%=txtUserName.ClientID%>").value);
}
</script>
Your Name :
<asp:TextBox ID="txtUserName" runat="server"></asp:TextBox>
<input id="btnGetTime" type="button" value="Show Current Time" onclick="ShowCurrentTime()" />
</div>
C#
[System.Web.Services.WebMethod]
public static void GetCurrentTime(string name)
{
string abc = "Hello " + name + Environment.NewLine + "The Current Time is: "
+ DateTime.Now.ToString();
}
VB
<System.Web.Services.WebMethod> _
Public Shared Sub GetCurrentTime(name As String)
Dim abc As String = (Convert.ToString("Hello ") & name) + Environment.NewLine + "The Current Time is: " + DateTime.Now.ToString()
End Sub
Screenshot
