Here is a complete working example:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script>
(function () {
var cx = '012117305473792254352:kosbw5yycts';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
'//www.google.com/cse/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<gcse:search xmlns:gcse="#unknown"></gcse:search>
</div>
</form>
</body>
</html>
This answer was originally posted at:
How do I use google search on my webiste?[
^]
You can generate your key and complete tutorial from below link:
https://www.google.com/cse/[
^]