Having a lot of problems getting to grips with the Kentico CMS, but I'm finally getting somewhere close. I'm using a normal portal engine and running Kentico 5.5 RC2 on a local installation.

I currently have an events page which uses a repeater to display all of the events that are available on the system currently. I want to use a calendar to be able to filter the events in that repeater. How would I go about this?

有帮助吗?

解决方案

There are several ways.

  • Custom user control
  • Custom web part
  • Query string parameters

The easiest would be the last one. Or a combination of the first two with the last one. Add your calendar control via your preferred method (an AJAX Calendar, jQuery calendar, <asp:Calendar>, or whatever you like) and have it populate in a text field. Then have that run some JavaScript to change the URL query string which will reload the page.

Go to your Kentico repeater's web part properties. In the Content filter->WHERE condition field, you can write a standard SQL WHERE clause and inject query string parameters via the special macro: {?QUERYSTRINGPARAMETERNAME?}. For example http://url/page?myfilter=2 would be {?myfilter?}. That would make the WHERE clause something like: {?myfilter?} = '' OR {?myfilter?} = SqlFieldToCompare.

Kentico claims they escape that macro for security, though I haven't personally confirmed that. Works for us though.

If you went with a customer user control or web part, you could use safer postback methods with a Control macro (instead of the above QueryString macro).

For more info on macros, see the Developer's Guide Appendix A Macros.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top