从后面的aspx页面方法调用code [英] Call code behind method from aspx page
本文介绍了从后面的aspx页面方法调用code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这样
<asp:Image ID="ImgProduct" runat="server" ImageUrl='<%# FormatImageUrl("10")%>' />
在code后面我有
就像一个方法
and in code behind i have a method like
protected string FormatImageUrl(string s)
{
return "image"+s;
}
当我朗姆酒code我期待与SRC =image10的HTML图像标记
将呈现。
when i rum the code i am expecting that an HTML image tag with src="image10" will render.
但没有任何反应
为什么?
任何线索?
but nothing happens why? any clues?
我在asp.net。不MVC
i am in asp.net . not mvc
推荐答案
在aspx页面
<asp:Image ID="ImgProduct" runat="server" ondatabinding="ImgProduct_DataBinding" />
在CS文件中使用这种
in the cs file use this
protected void Page_Load(object sender, EventArgs e)
{
ImgProduct.DataBind();
}
protected void ImgProduct_DataBinding(object sender, EventArgs e)
{
ImgProduct.ImageUrl = "Image pathe + name";
}
这篇关于从后面的aspx页面方法调用code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文