以显示相同的页作为在ASP.Net搜索控制在搜索结果最好的方式 [英] best way to display search results on the same page as the search control in ASP.Net

查看:99
本文介绍了以显示相同的页作为在ASP.Net搜索控制在搜索结果最好的方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面上的两个控制,一个是搜索条目和提交控制,另一种是控制搜索结果,它们具有由于网站的布局进行分离。林寻找具有搜索控制不同的方式提交显示在结果控制搜索结果,起初我不是操心回传,即时通讯更多的困扰两件事

I have two controls on a page, one is a search entry and submission control the other is the search results control, they have to be separated due to the layout of the site. Im looking at different ways of having the search control submit displaying the search results in the results control, initially im not bother about postbacks, im more bothered about two things

1)如何通过选择搜索项回到同一页面(或确实显示的结果)查询字符串,hiddenfield,会话视图状态(有效地隐藏字段)控制?

1) How do i pass the selected search terms back to the same page (or indeed to the control that displays the results) QUerystring, hiddenfield, session, viewstate (effectively hidden field)?

2)如何真正使页面提交自己。

2) how do i actually make the page submit to itself.

道歉,如果这是一个有点基本的,但我不是一个ASP.Net专家

apologies if this is a bit basic but im not an ASP.Net expert

推荐答案

有很多,很多方面做了什么你问,老实说我不知道​​,有一个正确的答案。这一切都取决于你的开发风格,你正在试图解决的问题。

There are many, many ways for doing what you are asking and to be honest I'm not sure that there is a right answer. It all depends on your development style and the problem that you are trying to solve.

我的经验与问候了相当数量写的搜索界面和使用查询字符串,我的意见是通过搜索条件的好方法。然而,这有它的advatages和它的缺点。

I have a fair amount of experience with regards to writing search interfaces and in my opinion using the query string is a good way of passing search criteria. However this has its advatages and its disadvantages.

优点:

  • 您可以简单地通过传递查询字符串到一个搜索结果页从您的网站或外部网站的任何地方。

  • You can get to a search results page from anywhere in your site or an external site simply by passing a query string.

您的搜索结果可以很容易地被抓取,因为它们是在你的网站只是网页。

Your search results can be crawled easily as they are just pages on your site.

查询字符串是使用相当简单。

Query strings are fairly simple to use.

用户可以看到它是什么,他们正在寻找在查询字符串。 (然而,这可能是取决于它的使用是一件坏事。)

The user can see what it is they are searching for in the query string. (However this might be a bad thing depending its use.)

用户可以预定标志thier检索算法的结果(感谢弗雷德里克·莫克)

Users can book mark thier serach results (Thanks Fredrik Mörk)

缺点:

  • 您可能需要花时间来让你的搜索条件看pretty的。 I.E.你想让你的用户只是看到一个ID,这意味着什么给他们?

  • You might have to take the time to make your search criteria look pretty. I.E. Do you want your users just to see an id that means nothing to them?

您可能会遇到问题HTML编码搜索条件,他们将需要传递作为查询字符串参数。编码可以很容易做到的,但它可以,如果你使用的是保留字符其他东西导致你头疼。

You may have problems html encoding your search criteria as they will need to be passed as a query string argument. Encoding can be done easily but it can cause you a headache if you are using reserved characters for other things.

您的用户可以看到他们正在搜索的内容。 (就像我说的,这可能是好事还是坏事。)

Your users can see what they are searching for. (Like I said this might be a good or a bad thing.)

您的查询字符串可能会变得太长了。

Your query string might become far too long.

有可能是我没有想到的一些其他的东西,但是,让你的想法。

There are probably some other things that I have not thought of but that gives you an idea.

至于张贴页面返回给自己再有这样做的几种方法,但尝试提交按钮或锚标记以#号作为href属性。

As for posting a page back to itself again there are a few ways of doing this but try a submit button or anchor tag with a # sign as the href attribute.

另一个要考虑可能使用的URL重写,使你的丑查询字符串一个很好看的URL。

Another thing to think about might be using a url rewriter to make your ugly query string a nice looking URL.

例如:

used_car_search.aspx使=福特和放大器;?模型=焦点

used_car_search.aspx?make=ford&model=focus

将变成:

used_ford_focus.html

used_ford_focus.html

编码快乐:)

这篇关于以显示相同的页作为在ASP.Net搜索控制在搜索结果最好的方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆