在 aspx 页面上实施 Google 自定义搜索的最佳方式
Google 自定义搜索代码作为表单标签提供。 但是,Asp.net 只允许页面上有单个表单标记。 实现其代码的最佳方法是什么,以便您可以将其包含在 aspx 页面上(例如作为母版页或导航元素的一部分)。
Google custom search code is provided as a form tag. However, Asp.net only allows a single form tag on a page. What is the best way to implement their code so you can include it on an aspx page (say as part of a Masterpage or navigation element).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
一个 ASP.NET 页面上可以有多个表单标记。 限制在于服务器端 (runat="server") 表单标记。
您可以实现两个(或多个)表单标记,只要其中一个具有 runat="server" 属性并且一个不包含在另一个中即可。 例子:
You can have multiple form tags on an ASP.NET page. The limitation is on server-side (runat="server") form tags.
You can implement two form tags (or more) as long as only one has the runat="server" attribute and one is not contained in the other. Example:
您可以拥有多个表单标签,但请注意它们不能嵌套。 在这种情况下,您会遇到各种奇怪的情况(例如,我见过嵌套表单的开始标记显然被忽略,然后其结束标记最终关闭“父”表单的情况)。
You may be able to have multiple form tags, but note that they cannot be nested. You'll run into all kinds of weirdness in that scenario (e.g., I've seen cases where the opening tag for the nested form apparently gets ignored and then its closing tag winds up closing the "parent" form out).
您需要删除表单标签并使用 javascript 发送查询。 看一下
http://my6solutions.com/post/2009/04/19/Fishing-Google-Custom-Search-nested-form-tags-in-asp-net-pages.aspx
我已经包含了之前以及代码之后。 所以您可以看到我为将其与 blogengine .net 集成所做的工作。
You'll need to remove the form tag and use javascript send the query. Have a look at
http://my6solutions.com/post/2009/04/19/Fixing-Google-Custom-Search-nested-form-tags-in-asp-net-pages.aspx
I have included the before and after code as well. So you can see what I've done to integrate it with blogengine .net.
你可以使用 JavaScript:
You could use Javascript: