使 Google Searchbox 代码与 ASP.NET WebForms 兼容
我获得了以下代码来集成到我的 ASP.NET WebForms 页面中:
<form action="http://www.google.com/cse" id="cse-search-box" target="_blank">
<div>
<input type="hidden" name="cx" value="partner-pub-8127518365728966:9snx3s9v6fx" />
<input type="hidden" name="ie" value="ISO-8859-1" />
<input type="text" name="q" size="25" /><br />
<input type="submit" name="sa" value="Search" class="formoutput"/>
</div>
</form>
<script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&lang=en"></script>
但是,我不确定如何执行此操作,因为这会带来额外的表单元素。以前是否有人将其翻译为与 ASP.NET WebForms 一起使用,如果是的话,您可以帮助我吗?
谢谢!
I was provided the following code to integrate into my ASP.NET WebForms page:
<form action="http://www.google.com/cse" id="cse-search-box" target="_blank">
<div>
<input type="hidden" name="cx" value="partner-pub-8127518365728966:9snx3s9v6fx" />
<input type="hidden" name="ie" value="ISO-8859-1" />
<input type="text" name="q" size="25" /><br />
<input type="submit" name="sa" value="Search" class="formoutput"/>
</div>
</form>
<script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&lang=en"></script>
However, I'm not sure how to do this because of the extra form element that this poses. Has somebody translated this to work with ASP.NET WebForms previously, and if so can you help me out?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请看这里:http://am22tech.com/s/22/Blogs/post/2010/05/26/How-can-I-add- Google-search-box-to-my-website-on-master-page-with-aspnet.aspx
这有点像黑客,但想法是执行以下操作:
这篇文章非常详细,如果您不介意使用 iFrame,那么它应该可以回答您的问题。
更新
Scott Mitchell 发布了一篇非常详细的文章,其中不使用 iFrame。它看起来需要更多的工作来实施,但可能是更好的选择。
网址:http://dotnetslackers .com/articles/aspnet/Implementing-Search-in-ASP-NET-with-Google-Custom-Search.aspx
Take a look here: http://am22tech.com/s/22/Blogs/post/2010/05/26/How-can-I-add-Google-search-box-to-my-website-on-master-page-with-aspnet.aspx
It's a bit of a hack but the idea is to do the following:
The article is pretty detailed and, if you don't mind using an iFrame, then it should answer your question.
Update
Scott Mitchell has posted a very detailed article that does not use iFrames. It looks like more work to implement but may be the better choice.
URL: http://dotnetslackers.com/articles/aspnet/Implementing-Search-in-ASP-NET-with-Google-Custom-Search.aspx