How to access a function in a codebehind file?
-
Hi! Im working on a commerce server site (starting from the microsoft "startersite"). I have built a leftpane usercontrol, with 2 picture buttons. Id like to be able to change the imageUrl:s of these at runtime by using a function in the codebehind file. My aspx file looks like this: <%@ Control Language="c#" AutoEventWireup="false" Codebehind="LeftPane.ascx.cs" Inherits="Microsoft.Solutions.Applications.LeftPane" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
-
Hi! Im working on a commerce server site (starting from the microsoft "startersite"). I have built a leftpane usercontrol, with 2 picture buttons. Id like to be able to change the imageUrl:s of these at runtime by using a function in the codebehind file. My aspx file looks like this: <%@ Control Language="c#" AutoEventWireup="false" Codebehind="LeftPane.ascx.cs" Inherits="Microsoft.Solutions.Applications.LeftPane" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
Hi there, You cannot use an inline expression to call a method and assign the value to the property of a web control. Instead, you should use a data binding expression:
<asp:ImageButton id="productsButton" runat="server" ImageUrl='<%# getImage("products") %>'></asp:ImageButton>
and remember to call the
DataBind
method in the Page_Load for example:productsButton.DataBind();