Contants and Parameter Name

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a global class GClass with 2 contants. Both are declared public in the
form:

PUBLIC Const Const1 = "xxx". When I try to use the constant as a default
value (see code excerpt below) the program bombs, but when I use a hardcoded
value it works fine. Any ideas?

Failing Version:

<SelectParameters>
<asp:Parameter Name="Catalog" Type="String"
DefaultValue="<%
GClass.Const1 %>" />

Working Version:

<SelectParameters>
<asp:Parameter Name="Catalog" Type="String"
DefaultValue="xxx" />

Thanks,
David
 
Unless you have ported the framework to an Atari, I don't really think
that the program bombs. ;)

What error message do you get? Often the error message tells you exactly
what is wrong.
 
What I meant is that the constant that he is declaring, he should make
it a static variable, because he is trying to access it using the Class
name.

You are right, that you cannot declare a constant static. :)

- V
 
dwg1011 said:
I have a global class GClass with 2 contants. Both are declared
public in the form:

PUBLIC Const Const1 = "xxx". When I try to use the constant as a
default value (see code excerpt below) the program bombs, but when I
use a hardcoded value it works fine. Any ideas?

Failing Version:

<SelectParameters>
<asp:Parameter Name="Catalog"
Type="String"
DefaultValue="<%
GClass.Const1 %>" />

Shouldn't that be:-
<asp:Parameter Name="Catalog"
Type="String"
DefaultValue="<%=GClass.Const1 %>" />

?

i.e. no new line splitting the name/value pair to potentially confuse it,
and an equals sign.

Andrew
 
The spacing was just the way it posted. If I am not mistaken the =varname is
"classic" ASP formatting while .net does not require it.

David
 
The spacing was just the way it posted. If I am not mistaken the
=varname is "classic" ASP formatting while .net does not require it.

Did you try it? I only use code-behind rather than in-line code.

What actually goes wrong? "Bombs" is vague.


*However* I now think it can't work that way. You would have to do it like:-

<%@ Page Language="VB" %>
<script runat="server">
Const const1 as string="xxx"
Sub Page_Load(obj as object, e as eventargs)
Catalog.DefaultValue=const1
End Sub
</script>
[other stuff]
<SelectParameters>
<asp:Parameter Id="Catalog" Name="Catalog" Type="String" />

Any use?

Andrew
 
Back
Top