Wednesday, March 21, 2012

HTML call const value

I have a constants.vb file with the following:

Public Class Constants
Public Const strRedAsterisk As String = "<font color=""#FF3300"">*</font>"
End Class

I have a login.aspx page. In html I have code:


<TD width="25%">Login ID <%# Constants.strRedAsterisk%></TD>

I get an error? I response.write Constants.strRedAsterisk in behind code and it works.

How can I call it in HTML ?Hi,

Try this :

<TD width="25%">Login ID <%=Constants.strRedAsterisk%></TD>

HTH
No doesn't work.

I get error:

BC30456: 'strRedAsterisk' is not a member of 'Microsoft.VisualBasic.Constants'.

I don't get it.
I put it in another class file called class1.

error message:

Name 'Class1' is not declared.

In code behind of aspx page - it works... But not when I call it in html view page. Do I have to set something on the top of the page?
Hi,

Use namespace as below :


<TD width="25%">Login ID <%=YourApplicationNameSpace.Constants.strRedAsterisk%></TD>

HTH
Awesome. Thanks

Is there a command line I can use so it inherits namespace and I don't have to put namespace in front of constants?
Also what if my applicationname changes later on down the road. Isn't it better not to use namespace ?

No comments:

Post a Comment