如何将 ashx 用于代码后面定义的 html 图像?

发布于 2024-11-17 03:12:09 字数 357 浏览 3 评论 0原文

当我在后面的代码中定义 HTMl 图像时,ashx 处理程序显示图像时遇到问题。如果我在 ascx 中定义,则图像会被拉得很好,但如果我在 .cs 中定义,则图像不会被拉得很好。

这就是我

 HtmlImage img1 = new HtmlImage();
 img1.Src = "imageout.ashx?PageID=" + PageID.ToString() + "&DIImageID=" + DIImageID.ToString();

在图像的地方显示 src“imageout.ashx?.......”的文本的方式,

我在这里缺少什么?帮帮我吧。

提前致谢

I have an issue with ashx handler for showing image when i defined HTMl image in code behind. IF i define in ascx, the image is pulled fine but not if i define in .cs.

This is the way i

 HtmlImage img1 = new HtmlImage();
 img1.Src = "imageout.ashx?PageID=" + PageID.ToString() + "&DIImageID=" + DIImageID.ToString();

In the place of the image, it displays the text of src "imageout.ashx?......."

What is it i am missing here? Help me out.

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

傲性难收 2024-11-24 03:12:09

试试

img1.Attributes["src"] = "imageout.ashx?PageID=" + PageID.ToString() + "&DIImageID=" + DIImageID.ToString();

这对我有用。

Try

img1.Attributes["src"] = "imageout.ashx?PageID=" + PageID.ToString() + "&DIImageID=" + DIImageID.ToString();

This works for me.

掩耳倾听 2024-11-24 03:12:09

试试这个

img1.Src = ResolveClientUrl(string.Format("~/imageout.ashx?PageID={0}&DIImageID={1}", PageID, DIImageID));

技巧在于 ResolveClientUrl 方法调用。使用 String.Format 方法只是为了增加可读性。

用于用户控制:

 img1.Src = ResolveUrl(string.Format("~/imageout.ashx?PageID={0}&DIImageID={1}", PageID, DIImageID));

Try this

img1.Src = ResolveClientUrl(string.Format("~/imageout.ashx?PageID={0}&DIImageID={1}", PageID, DIImageID));

The trick is in the ResolveClientUrl method call. String.Format method has utilized just for increase readability.

For use in user control:

 img1.Src = ResolveUrl(string.Format("~/imageout.ashx?PageID={0}&DIImageID={1}", PageID, DIImageID));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文