FormView C# 切换图像可见性
我有一个显示按钮和图像的 FormView。 当用户单击 linkButton 时,我想显示/隐藏图像的可见性。
<asp:FormView ID="FormOptions" runat="server" CellPadding="4" DataSourceID="dsOpts" ForeColor="#333333">
<ItemTemplate>
<asp:Button ID="ButtonHide" runat="server" Text='<%# Eval("optDisplay")%>' onclick="ButtonHide_Click"/>
<asp:Image ID="ImageFP" ImageUrl='<%# Eval("optImage")%>' runat="server" CssClass="optImages"/>
</ItemTemplate>
</asp:FormView>
然后在我的代码后面,我有:
protected void ButtonHide_Click(object sender, EventArgs e)
{
ImageFP.visible = false;
}
但是,我收到一条错误消息,说它找不到 ImageFP。当图像不是 FormView 的一部分时,这有效,所以我猜我需要更直接地指定图像的路径。我是 Visual Basic 的新手,感谢您的指导!
I have a FormView that displays a Button and an image.
When the user clicks the linkButton, I want to show/hide the visibility of image.
<asp:FormView ID="FormOptions" runat="server" CellPadding="4" DataSourceID="dsOpts" ForeColor="#333333">
<ItemTemplate>
<asp:Button ID="ButtonHide" runat="server" Text='<%# Eval("optDisplay")%>' onclick="ButtonHide_Click"/>
<asp:Image ID="ImageFP" ImageUrl='<%# Eval("optImage")%>' runat="server" CssClass="optImages"/>
</ItemTemplate>
</asp:FormView>
Then in my code behind, I have:
protected void ButtonHide_Click(object sender, EventArgs e)
{
ImageFP.visible = false;
}
However, I get an error saying it cannot find ImageFP. This works when the image is not part of a FormView so I'm guessing I need to specify more directly the path to the image. I'm new with Visual Basic and appreciate any guidance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要获取对表单视图的项目模板内的图像的引用
像下面这样
You need to get a refrence to the image inside the item template of the Form view
like the following