Regex not working in page_load

T

tshad

I am trying to get a regular expression to work and I keep getting the
following error:

Compiler Error Message: BC30469: Reference to a non-shared member requires
an object reference.

The page is:

**********************************************************************************
<%@ Page Language="VB" trace="true" debug="true" ContentType="text/html"
ResponseEncoding="iso-8859-1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<script runat="server">
sub page_load(s as object,e as eventargs)
'dim testString as String = "a test"
testLabel.text = "a test"

testLabel.text = Regex.Replace(testLabel.text,"( and not | and )")
response.write(testLabel.text)
end sub
</script>
<body>
<asp:label id = "testLabel" runat="server"/>
</body>
</html>
***********************************************************************************

I tried it with both testLabel.text (which is an asp:label) and also
testString (string) and got the error with both.

I do exactly the same thing in my other asp pages to make a currency value
into a decimal value.

objCmd.parameters.add("@WagesMin",SqlDbType.Money).value =
Regex.Replace(WagesMin.Text,"\$|\,","")

This works fine.

What is the difference?

Thanks,

Tom
 
T

tshad

tshad said:
I am trying to get a regular expression to work and I keep getting the
following error:

Compiler Error Message: BC30469: Reference to a non-shared member requires
an object reference.

The page is:

**********************************************************************************
<%@ Page Language="VB" trace="true" debug="true" ContentType="text/html"
ResponseEncoding="iso-8859-1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<script runat="server">
sub page_load(s as object,e as eventargs)
'dim testString as String = "a test"
testLabel.text = "a test"

testLabel.text = Regex.Replace(testLabel.text,"( and not | and )")
response.write(testLabel.text)
end sub
</script>
<body>
<asp:label id = "testLabel" runat="server"/>
</body>
</html>
***********************************************************************************

I tried it with both testLabel.text (which is an asp:label) and also
testString (string) and got the error with both.

I do exactly the same thing in my other asp pages to make a currency value
into a decimal value.

objCmd.parameters.add("@WagesMin",SqlDbType.Money).value =
Regex.Replace(WagesMin.Text,"\$|\,","")

This works fine.

What is the difference?

I did try to put the code that doesn't work next to the one that does and it
still doesn't work.

if WagesMax.Text = "" then
objCmd.parameters.add("@WagesMax",SqlDbType.Money).value = 0.00
else
objCmd.parameters.add("@WagesMax",SqlDbType.Money).value =
Regex.Replace(WagesMax.Text,"\$|\,","")
testLabel.text = Regex.Replace(testLabel.text,"( and not | and )")
end if

I get the error on the testLabel.text line. The line above it works fine.

Tom
 
T

tshad

tshad said:
I did try to put the code that doesn't work next to the one that does and
it still doesn't work.

if WagesMax.Text = "" then
objCmd.parameters.add("@WagesMax",SqlDbType.Money).value = 0.00
else
objCmd.parameters.add("@WagesMax",SqlDbType.Money).value =
Regex.Replace(WagesMax.Text,"\$|\,","")
testLabel.text = Regex.Replace(testLabel.text,"( and not | and )")
end if

I get the error on the testLabel.text line. The line above it works fine.

I found the problem.

There are 3 parameters. I had originally used an example from vbscript
which only has 2 parameters.

Thanks,

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top