|
| Cannot get the syntax correct in my aspx to call my handler |
 |
Sun, 23 Mar 2008 02:41:39 +000 |
I have created this simple handler to splice a comma seperated text to add a
link as shown below:
"C#" Class="TagsHandler" %>
using System;
using System.Web;
public class TagsHandler : IHttpHandler
{
public void ProcessRequest (HttpContext context)
{
string resp = string.Empty;
string Tags = context.Request.QueryString["Tags"];
//first get the various tags from the inputstring[] tagsArr =
Tags.Split(',');
//iterate through and build a linkforeach (string s in tagsArr)
{
resp += string.Format("<a
href=\"SearchResults.aspx?Tag=\"></a> ",s,s);
}
context.Response.ContentType = "text/html";
context.Response.Write(resp);
}
public bool IsReusable
{
get { return true;}
}
}
However when I try calling the handler from my aspx page as shown below:
<p><%# TagsHandler.ashx?Tags=Banana%></p>
I get this error: Syntax error, ':' expected
I can't figure out how to write the syntax in the aspx page. Anyone how I
should be calling the handler?
Thanks, Bill N
|
| Post Reply
|
| Re: Cannot get the syntax correct in my aspx to call my handler |
 |
Sun, 23 Mar 2008 03:41:49 +000 |
Hi! I don't know if you are familiar with ajax. What you have to do is execute
an asynchronous call to the web handler.
Here you have an example of how to do it
http://www.viawindowslive.com/Articles/VirtualEarth/InvokingserversidecodeusingA
JAX.aspx
On the example, the function where you should process the response and write it
on the page is XMLHttpRequestCompleted
|
| Post Reply
|
|
|
|
|
|
|
|
|
|