views:

161

answers:

1

I'm new to jquery and asp.net so please forgive if this is an obvious question. I'm using a jquery autocomplete plugin which requires that the page it looks up asynchronously for data is in this format as pure text only:

product1|price1
product2|price2
product3|price3

WITHOUT ANY OTHER HTML MARKUP. Any other html tags seems to cause problems. Normally for a page like that I would use a repeater and some standard database calls and output the 2 fields. This however creates html tags.

How can I output this data as text only with no other markup whatsoever?

+1  A: 

If you have a bare page with no master page referenced a repeater shouldn't produce any html. Make sure in the HTML view you only have:

<asp:Repeater ID="outRepeater" runat="server">
- your template here
</asp:Repeater>

An alternative would be to add a new Handler to your project which is a class that implements the IHttpHandler interface. This would allow you to output your code directly. This would end up looking like:

public class MyOutputHandler : IHttpHandler {
  public bool IsReusable { return false; }
  public void ProcessRequest(HttpContext context) {
    context.Response.Write("product1|price1");
  }
}

If you have added this to a project as a new Handler (from add items) it should have a .ashx extension. Otherwise you'll need to register it in your web.config with its type and filename.

Duncan
The first method didn't work because I have a themed css file which apparently requires a head tag. The general handler worked great and I was able to get the exact output I needed. Thank you.
muhan