2014年7月13日 星期日

[RESOLVED] handler in asp.net


hi


i have an .aspx page and have 3 webusercontrol in it.each usercontrol has a generic  handler,when i run the .aspx page,i dont see the correct input of usercontrols.


but when i  use the page with just one of the usercontrol,it works correctly.is it because of having multiple handler in one page?can we have multiple handler in one page?



Is it the same control 3 times?  If so it could be the html you're generating.  If it has html elements with ids that are accessed via javascript then it might be that multiple ids are confusing your javascript and causing it to give unexpected results. 
That's just a guess though, we'll need more info and maybe some sample code.



Hi,


For this situation, I also create two web user controls and each user control has a generic handler to retrieve the images, then add the two user controls within the same page, and both works fine. Below is my testing example:


//first handler 
public class ImageTextHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
string text = context.Request.QueryString["text"];
context.Response.ContentType = "image/jpg";
context.Response.WriteFile("~/images/"+text+".jpg");
}

public bool IsReusable
{
get
{
return false;
}
}
}


//second handler

public class ImageTextHandler2 : IHttpHandler
{

public void ProcessRequest(HttpContext context)
{
string text = context.Request.QueryString["text"];
context.Response.ContentType = "image/jpg";
context.Response.WriteFile("~/images/" + text + ".jpg");
}

public bool IsReusable
{
get
{
return false;
}
}
}

//user control 1:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ImageTextHandler1.ascx.cs" Inherits="Testing.UserControls.ImageTextHandler1" %>









//user control 2:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ImageTextHandler2.ascx.cs" Inherits="Testing.UserControls.ImageTextHandler2" %>








//.aspx page:

<%@ Register Src="~/UserControls/ImageTextHandler1.ascx" TagPrefix="uc1" TagName="ImageTextHandler1" %>
<%@ Register Src="~/UserControls/ImageTextHandler2.ascx" TagPrefix="uc1" TagName="ImageTextHandler2" %>





















Regards






沒有留言:

張貼留言