Sunday, August 18, 2013

Google Search Advanced

<html><head><title> Search</title></head>
<body bgcolor=ffffff>

<%
if request.querystring="" then
 sendform()
else
 sendform()

' You must ask Google for a key
key = "00000000000000000000000000000000000"

' The URL where the script is located
URL = "http://www.yourdomain/yourscript.asp"


SoapText = "<?xml version='1.0' encoding='UTF-8'?><SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsi='http://www.w3.org/1999/XMLSchema-instance' xmlns:xsd='http://www.w3.org/1999/XMLSchema'><SOAP-ENV:Body><ns1:doGoogleSearch xmlns:ns1='urn:GoogleSearch' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'><key xsi:type='xsd:string'>" & key &"</key><q xsi:type='xsd:string'>" & request.querystring("keywords") & "</q><start xsi:type='xsd:int'>" & request.querystring("h") & "</start><maxResults xsi:type='xsd:int'>10</maxResults><filter xsi:type='xsd:boolean'>true</filter><restrict xsi:type='xsd:string'></restrict><safeSearch xsi:type='xsd:boolean'>false</safeSearch><lr xsi:type='xsd:string'></lr> <ie xsi:type='xsd:string'>latin1</ie><oe xsi:type='xsd:string'>latin1</oe></ns1:doGoogleSearch></SOAP-ENV:Body></SOAP-ENV:Envelope>"

Googleurl = "http://api.google.com/search/beta2"

Set objXML = CreateObject("Microsoft.XMLHTTP")
objXML.open "POST",Googleurl,"False"
objXML.setRequestHeader "Man", "POST"+" "+Googleurl+" HTTP/1.1"
objXML.setRequestHeader "MessageType", "CALL"
objXML.setRequestHeader "Content-Type", "text/xml"
objXML.send SoapText

ResponsePage = objXML.responseText
Set objXML = Nothing

ResponsePage=Replace(ResponsePage," xsi:type=" & CHR(34) & "xsd:string" & CHR(34),"")
ResponsePage=Replace(ResponsePage,"&lt;b&gt;","")
ResponsePage=Replace(ResponsePage,"&lt;/b&gt;","")
ResponsePage=Replace(ResponsePage,"&lt;br&gt;","<br>")

EstimatedResults=left(ResponsePage,inStr(ResponsePage,"</estimatedTotalResultsCount>")-1)
EstimatedResults=right(EstimatedResults,len (EstimatedResults)-inStr(EstimatedResults,"<estimatedTotalResultsCount")-46)
 Response.write ("Estimated results for <b>" & q & "</b>: " & EstimatedResults & " &nbsp; <A href=" & request.servervariables("URL") & "?keywords=" & request.querystring("keywords") & "&h=" & request.querystring("h"))+10 & "><font size=2>next 10</font></a><HR>")

public namearray
namearray=split (ResponsePage,"<item xsi:type=" & CHR(34) & "ns1:ResultElement" & CHR(34) & ">")
max=ubound(namearray)-1

for i=1 to max

theurl=left(namearray(i),inStr(namearray(i),"</URL>")-1)
theurl=right(theurl,len (theurl)-instr(theurl,"<URL>")-4)

thetitle=left(namearray(i),inStr(namearray(i),"</title>")-1)
thetitle=right(thetitle,len (thetitle)-inStr(thetitle,"<title>")-6)
if thetitle="" then
thetitle="No Title"
end if

AA=inStr(namearray(i),"</snippet>")-1
thedescription=left(namearray(i),AA)
thedescription=right(thedescription,len (thedescription)-inStr(thedescription,"<snippet>")-8)

Searchresults=Searchresults & "<p><a href=" & theurl & ">" & thetitle & "</a><br>" & thedescription & "<br><font size=2>" & theurl & "</font>"

next


Response.write(Searchresults)

end if
 %>
<% Sub SendForm() %>

<form method=get action=<% =request.servervariables("URL") %>>
Find Keywords <input type=text name=keywords size=15>
 <input type=hidden name=h value=0> <input type=submit value="Google Search">
</form>

<% end sub%>
<HR>
Script provided by <A HREF=http://www.asptutorial.info>AspTutorial.info</a>

</body></html>

Code for google map - asp.net

1.jscript on top master page

<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=abcdefg&sensor=true_or_false"
        type="text/javascript"></script>

    <script type="text/javascript">

    function initialize() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng("<%=_latitude%>","<%=_longtitude%>"), 13);
        map.setUIToDefault();
      }
    }


    </script>


2.jscript on bottom master page

<script language="javascript" type="text/javascript">
GUnload();
initialize();  
</script>


3.delaring div in master page html source

<div id="map_canvas" style="width: 293px; height: 226px">
                                        </div>

function before page load im master page code page

public decimal _latitude, _longtitude;
  
function in page load of master page

 _latitude = Convert.ToDecimal(9.583333);
        _longtitude = Convert.ToDecimal(76.516667);



Textbox to file and file to textbox conversions in asp.net

using 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;
using System.IO;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {//code to convert text in a textbox to a file
        TextWriter w = File.CreateText(Server.MapPath("folder/s.xml"));
        w.WriteLine(TextBox1.Text);
        w.Close();

     //code to convert text in a file to textbox
        StreamReader a = File.OpenText(Server.MapPath("folder/ss.txt"));
        String q = a.ReadToEnd();
        TextBox2.Text = q;
        a.Close();


    }
}

Change font color of label control dynamically in asp.net

eg:  Label1.ForeColor = System.Drawing.Color.Gray;