Addon Features using google services for website like custom search-translator and many more

Some Additional Features for any website...
1) Google Language Translator for website a) vary simple code just copy paste that code to your website & it will show you dropdown list of many languages to make your website globally reachable.
<div> <div id="google_translate_element"></div><script> function googleTranslateElementInit() { new google.translate.TranslateElement(
{pageLanguage: 'en', multilanguagePage: true, layout:
google.translate.TranslateElement.InlineLayout.SIMPLE }, 'google_translate_element'); } </script>
<script src="//translate.google.com/translate_a/element.js?cb=
googleTranslateElementInit"></script> </div>

b) Google Language Translator with flag
<a href="#" target="_blank" rel="nofollow" onclick="window.open('http://www.google.com/translate?u=' +encodeURIComponent(location.href)+'&langpair=en%7Cfr&hl=en&ie=UTF8'); return false;" title="Google-Translate-English to French ">French</a>
// you can use different languages their instead of French & can use Flag image instead of text..

2) Google Service Hindi Input box/ textbox
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <script type="text/javascript" src="https://www.google.com/jsapi"> </script> <script type="text/javascript">   // Load the Google Transliterate API   google.load("elements", "1", { packages: "transliteration" });   function onLoad() {   var options = { sourceLanguage: google.elements.transliteration.LanguageCode.ENGLISH,
destinationLanguage: [google.elements.transliteration.LanguageCode.HINDI], 
shortcutKey: 'ctrl+g',transliterationEnabled: true }; // Create an instance on TransliterationControl with the required // options. var control = new google.elements.transliteration.TransliterationControl(options);     // Enable transliteration in the textbox with id     //'transliterateTextarea'. control.makeTransliteratable(['transliterateTextarea']);   } google.setOnLoadCallback(onLoad); </script> </head><body> Type in Hindi (Press Ctrl+g to toggle between English and Hindi)<br> <textarea id="transliterateTextarea" style="width:600px;height:200px"> </textarea> </body></html>

3) Google Plus Button for your website
<!-- Place this tag where you want the +1 button to render --> <g:plusone annotation="inline"></g:plusone> <!-- Place this render call where appropriate --> <script type="text/javascript"> (function() { var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = 'https://apis.google.com/js/plusone.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); })(); </script>

How Convert GridView to Word/Excel Asp.Net C# Code


How Convert A GridView to Word Document Or in Excel Sheet using C#.net Code in ASP.Net for Saving it.

// For pdf conversion we can use third party dll like ITextSharp 
// Or In Advance Browser like chrome there is option for save page as pdf...

C# Code : For GridView To Excel

 protected void btn_excel_Click(object sender, EventArgs e)
    {
          string attachment = "attachment; filename=myreport.xls";
          Response.Cache.SetCacheability(HttpCacheability.NoCache);
          Response.AddHeader("content-disposition", attachment);
          Response.ContentType = "application/ms-excel";
          StringWriter swriter = new StringWriter();
          HtmlTextWriter htmlwriter = new HtmlTextWriter(swriter);
 
          // Create a form to contain the gridview(MyGridView)
          HtmlForm mynewform = new HtmlForm();
          MyGridView.Parent.Controls.Add(mynewform);
          mynewform.Attributes["runat"] = "server";
          mynewform.Controls.Add(MyGridView);
          mynewform.RenderControl(htmlwriter);
          Response.Write(swriter.ToString());
          Response.End();
    }


C# Code : For GridView To Word

    protected void btn_word_Click(object sender, EventArgs e)
    {
          Response.AddHeader("content-disposition""attachment;filename=myreport.doc");
          Response.Cache.SetCacheability(HttpCacheability.NoCache);
          Response.ContentType = "application/vnd.word";
          System.IO.StringWriter swriter = new System.IO.StringWriter();
          System.Web.UI.HtmlTextWriter htmlwriter = new HtmlTextWriter(swriter);
 
          // Create a form to contain the gridview(MyGridView)
          HtmlForm mynewform = new HtmlForm();
          MyGridView.Parent.Controls.Add(mynewform);
          mynewform.Attributes["runat"] = "server";
          mynewform.Controls.Add(MyGridView);
          mynewform.RenderControl(htmlwriter);
          Response.Write(swriter.ToString());
          Response.End();
    }

create update delete xml in csharp asp.net


//How to create xml file using c#.net asp.net code
//Append Node/ Modify Node in XML using c#.net asp.net
//
using System.Xml;
using System.IO;
 protected void Button1_Click(object sender, EventArgs e)

{
  string filepath = MapPath("xml/XMLFile3.xml"); // path of xml where we want to save it
   create(filepath);
}

private void create(string filepath)    // filepath is path where we want to save xml file
{
   string xml = @"<?xml version='1.0' encoding='utf-8'?>
                    <ParentXMLNode>
                    <Header>
                           <xmlnode1>value1</xmlnode1>
                           <xmlnode2>value2</xmlnode2>
                    </Header>
                    <xmlnode3>value3</xmlnode3>
                    <xmlnode4>value4</xmlnode4>  
                    <Message>
                        <xmlnode5></xmlnode5>
                        <xmlnode5></xmlnode5>
                        <xmlnode6>
                               <Node1></Node1>
                        </xmlnode6>
                     </Message>
                    </ParentXMLNode>";

        XmlDocument docConfig = new XmlDocument();
        docConfig.LoadXml(xml);
        Literal1.Text = "<XMP>" + xml + "</XMP>";
        docConfig.Save(filepath);
    }