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 assing a value to alt from class file?

How to assing a value to alt from class file?

Scheduled Pinned Locked Moved ASP.NET
tutorialquestion
6 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
    Sam M
    wrote on last edited by
    #1

    Hi there, I'm having a webpage which has img control and i want to set alt message for that, but the message would be changable. So i want to put it in some class file. Below is my code but it's not working. Can u please suggest what i can do? <img border="0" id="ImgHeader" alt="<%= HardCodedValues.HeaderText %>" style="height: 185; width: 760" /> and my class file is: public class HardcodedValues { public static string HeaderText = "2K Billing"; }

    Regards n Thks Sam.M

    C 1 Reply Last reply
    0
    • S Sam M

      Hi there, I'm having a webpage which has img control and i want to set alt message for that, but the message would be changable. So i want to put it in some class file. Below is my code but it's not working. Can u please suggest what i can do? <img border="0" id="ImgHeader" alt="<%= HardCodedValues.HeaderText %>" style="height: 185; width: 760" /> and my class file is: public class HardcodedValues { public static string HeaderText = "2K Billing"; }

      Regards n Thks Sam.M

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      What does 'not working' mean ? What do you get ? I'd expect this to work.

      Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      S 1 Reply Last reply
      0
      • C Christian Graus

        What does 'not working' mean ? What do you get ? I'd expect this to work.

        Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

        S Offline
        S Offline
        Sam M
        wrote on last edited by
        #3

        The error which i'm getting is: Compiler Error Message: CS0103: The name 'HardCodedValues' does not exist in the current context Source Error: Line 24: <div align="center"> Line 25: <a href="http://www.2kmobilelink.com" target="_blank"> Line 26: <img border="0" id="ImgHeader" alt="<%= HardCodedValues.HeaderText %>" src='<%= ConfigurationManager.AppSettings["ImagePath"]%>2KMobileLinkHeader.jpg' Line 27: style="height: 185; width: 760" /></a> Line 28:

        Regards n Thks Sam.M

        C 1 Reply Last reply
        0
        • S Sam M

          The error which i'm getting is: Compiler Error Message: CS0103: The name 'HardCodedValues' does not exist in the current context Source Error: Line 24: <div align="center"> Line 25: <a href="http://www.2kmobilelink.com" target="_blank"> Line 26: <img border="0" id="ImgHeader" alt="<%= HardCodedValues.HeaderText %>" src='<%= ConfigurationManager.AppSettings["ImagePath"]%>2KMobileLinkHeader.jpg' Line 27: style="height: 185; width: 760" /></a> Line 28:

          Regards n Thks Sam.M

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          Ah - if you don't put your codebehind class in a namespace, I think the compiler invents one for you. Put the codebehind ( and thus the aspx reference to the class used ) in the same namespace as HardCodedValues

          Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

          S 1 Reply Last reply
          0
          • C Christian Graus

            Ah - if you don't put your codebehind class in a namespace, I think the compiler invents one for you. Put the codebehind ( and thus the aspx reference to the class used ) in the same namespace as HardCodedValues

            Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

            S Offline
            S Offline
            Sam M
            wrote on last edited by
            #5

            Sorry, i don't understand. Can u please give me some sample code

            Regards n Thks Sam.M

            C 1 Reply Last reply
            0
            • S Sam M

              Sorry, i don't understand. Can u please give me some sample code

              Regards n Thks Sam.M

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              In your ASPX replace <%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Request.Master" CodeBehind="CaseNotes.aspx.cs" Inherits="CaseNotes" %> with <%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Request.Master" CodeBehind="CaseNotes.aspx.cs" Inherits="MyNamespace.CaseNotes" %> and in your code behind replace public partial class CaseNotes : Page with namespace MyNamespace { public partial class CaseNotes : Page Now, make sure that MyNamespace is the same as the namespace for your HardCodedValues class.

              Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

              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