Some ASP.NET server controls depend on client script for their functionality. In addition, some functionality of ASP.NET pages relies on client script. It is useful to know how ASP.NET controls and pages use client script so that you understand how ASP.NET Web pages might be affected by differences in how browsers support client script.Client executes only JavaScript, DHTML and Markup tags only. To run client execution through server controls we have include attribute property to the button in the code.Following code snippet explain about client execution from server controls:JavaScript Script File codefunction test(){alert("Testing Server control to run client script");//confirm("Testing Server control to run client script");}Note: Javascript has two methods confirm() and alert() to display messageDesing .aspx code file <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ClientExec_ServerControl._Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <script language="javascript" type="text/jscript" src="JScript1.js"></script>
<title>Client execution from server control</title></head><body> <form id="form1" runat="server"> <div> </div> <p> <asp:Button ID="Button1" runat="server" style="top: 15px; left: 10px; position: absolute; height: 26px; width: 346px" Text="Server Button which will run client script" /> </p> </form></body></html>In the page load you can add this line for having client side validationButton1.Attributes.Add("onClick", "return test();");Code behind .cs file codeusing System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;namespace ClientExec_ServerControl{ public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Button1.Attributes.Add("onClick", "return test();"); } }}The above code will do the following: