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