Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to access a function in a codebehind file?

How to access a function in a codebehind file?

Scheduled Pinned Locked Moved ASP.NET
csharpvisual-studiocomsysadmintutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    spAAwn
    wrote on last edited by
    #1

    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"%>

    M 1 Reply Last reply
    0
    • S spAAwn

      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"%>

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      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();

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups