mojtaba_nava
یک شنبه 07 آذر 1389, 08:04 صبح
سلام دوستان
من يك مشكلي كه دارم اينكه اين كد ها رو كه در پايين براتون گزاشتم چطوري كار مي كنه؟
design:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_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">
<title>Google API:</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<strong><span style="font-size: 16pt; color: #ff0000; font-family: Courier New CE">
Google API In ASP.NET </span></strong>
<br />
<br />
<hr style="font-weight: bold; color: #006600; height: 5px"/>
<asp:Label ID="lblmsg" runat="server" Text=""></asp:Label>
<br />
<br />
<asp:TextBox ID="txtsearch" runat="server" BackColor="#FFFFC0" BorderColor="Black" Width="321px" Height="18px" ></asp:TextBox>
<asp:Button ID="btn1" runat="server" Text="Search" BackColor="#FFFFC0" BorderColor="#80FF80" ForeColor="#004000" OnClick="btn1_Click" Width="95px" />
<br />
<br />
<hr style="font-weight: bold; color: #ff3333; height: 1px; text-decoration: line-through" />
</div>
</form>
</body>
</html>
code behind:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btn1_Click(object sender, EventArgs e)
{
if (txtsearch.Text.Trim().Length == 0)
{
lblmsg.Text = "Please enter your query to search...";
}
else
{
Response.Redirect("SearchDetails.aspx?q="+txtsearch.Text);
}
}
}
default2.aspc(design)
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SearchDetails.aspx.cs" Inherits="SearchDetails" %>
<!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 id="Head1" runat="server">
<title>Google Search...</title>
<script src="http://www.google.com/jsapi?key=Add your key here" type="text/javascript"></script>
<script language="Javascript" type="text/javascript">
//<![CDATA[
google.load('search', '1');
function OnLoad() {
var searchControl = new google.search.SearchControl();
// Add in a full set of searchers
var localSearch = new google.search.LocalSearch();
searchControl.addSearcher(localSearch);
searchControl.addSearcher(new google.search.WebSearch());
searchControl.addSearcher(new google.search.VideoSearch());
searchControl.addSearcher(new google.search.BlogSearch());
searchControl.addSearcher(new google.search.NewsSearch());
searchControl.addSearcher(new google.search.ImageSearch());
searchControl.addSearcher(new google.search.BookSearch());
searchControl.addSearcher(new google.search.PatentSearch());
searchControl.draw(document.getElementById("myCtrl"));
// execute an inital search
searchControl.execute(GetQueryString("q"));
}
google.setOnLoadCallback(OnLoad);
//]]>
// Function to get Query String Value
function GetQueryString(query) {
hu = window.location.search.substring(1);
gy = hu.split("&");
for (i = 0; i < gy.length; i++) {
ft = gy[i].split("=");
if (ft[0] == query) {
return ft[1];
}
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="myCtrl" style="width:100%">
</div>
</form>
</body>
</html>
من يك مشكلي كه دارم اينكه اين كد ها رو كه در پايين براتون گزاشتم چطوري كار مي كنه؟
design:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_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">
<title>Google API:</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<strong><span style="font-size: 16pt; color: #ff0000; font-family: Courier New CE">
Google API In ASP.NET </span></strong>
<br />
<br />
<hr style="font-weight: bold; color: #006600; height: 5px"/>
<asp:Label ID="lblmsg" runat="server" Text=""></asp:Label>
<br />
<br />
<asp:TextBox ID="txtsearch" runat="server" BackColor="#FFFFC0" BorderColor="Black" Width="321px" Height="18px" ></asp:TextBox>
<asp:Button ID="btn1" runat="server" Text="Search" BackColor="#FFFFC0" BorderColor="#80FF80" ForeColor="#004000" OnClick="btn1_Click" Width="95px" />
<br />
<br />
<hr style="font-weight: bold; color: #ff3333; height: 1px; text-decoration: line-through" />
</div>
</form>
</body>
</html>
code behind:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btn1_Click(object sender, EventArgs e)
{
if (txtsearch.Text.Trim().Length == 0)
{
lblmsg.Text = "Please enter your query to search...";
}
else
{
Response.Redirect("SearchDetails.aspx?q="+txtsearch.Text);
}
}
}
default2.aspc(design)
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SearchDetails.aspx.cs" Inherits="SearchDetails" %>
<!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 id="Head1" runat="server">
<title>Google Search...</title>
<script src="http://www.google.com/jsapi?key=Add your key here" type="text/javascript"></script>
<script language="Javascript" type="text/javascript">
//<![CDATA[
google.load('search', '1');
function OnLoad() {
var searchControl = new google.search.SearchControl();
// Add in a full set of searchers
var localSearch = new google.search.LocalSearch();
searchControl.addSearcher(localSearch);
searchControl.addSearcher(new google.search.WebSearch());
searchControl.addSearcher(new google.search.VideoSearch());
searchControl.addSearcher(new google.search.BlogSearch());
searchControl.addSearcher(new google.search.NewsSearch());
searchControl.addSearcher(new google.search.ImageSearch());
searchControl.addSearcher(new google.search.BookSearch());
searchControl.addSearcher(new google.search.PatentSearch());
searchControl.draw(document.getElementById("myCtrl"));
// execute an inital search
searchControl.execute(GetQueryString("q"));
}
google.setOnLoadCallback(OnLoad);
//]]>
// Function to get Query String Value
function GetQueryString(query) {
hu = window.location.search.substring(1);
gy = hu.split("&");
for (i = 0; i < gy.length; i++) {
ft = gy[i].split("=");
if (ft[0] == query) {
return ft[1];
}
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="myCtrl" style="width:100%">
</div>
</form>
</body>
</html>