Saturday, March 31, 2012
Subroutine /helper function error
would be displayed inside a datalist control's <itemtemplate> )
<script language="VB" runat="server">
Public Sub checkforimg(ByVal Imagesubprod1 As String)
If Imagesubprod1 <> "" then
response.write(Imagesubprod1)
Else
response.write("nbsp;")
End If
End Sub
</script>
... but I get an "Overload resolution failed because no accessible
'ToString' can be called with these arguments:" error when it comes
time to check for the image as follows.
<%# checkforimg(DataBinder.Eval(Container.DataItem,
"Imagesubprod1"))%>
When I form the header for the sub as follows:
Public Sub checkforimg(ByVal Imagesubprod1 As String) As string
..i get an "Expected end of statement " error on this lineOn 10 Jun 2004 11:55:42 -0700, Chumley the Walrus <springb2k@.yahoo.com>
wrote:
> I'm using a subroutine/helper function display an image (the image
> would be displayed inside a datalist control's <itemtemplate> )
> <script language="VB" runat="server">
> Public Sub checkforimg(ByVal Imagesubprod1 As String)
> If Imagesubprod1 <> "" then
> response.write(Imagesubprod1)
> Else
> response.write("nbsp;")
> End If
> End Sub
> </script>
> ... but I get an "Overload resolution failed because no accessible
> 'ToString' can be called with these arguments:" error when it comes
> time to check for the image as follows.
> <%# checkforimg(DataBinder.Eval(Container.DataItem,
> "Imagesubprod1"))%>
looks like it's having trouble converting the value you're passing in thru
databinding to a String. If you have Option Strict on, you might try
either casting the value in the databinding statement to a string before
passing it in, or change the parameter in your method above to an Object
and then cast it inside the function itself.
Otherwise verify the value in your datasource is truly capable of being a
string.
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
IE does not support inline images, so you code should be writing something
like: <img src=url> not the binary image.
-- bruce (sqlwork.com)
"Chumley the Walrus" <springb2k@.yahoo.com> wrote in message
news:1ef65641.0406101055.8852102@.posting.google.com...
> I'm using a subroutine/helper function display an image (the image
> would be displayed inside a datalist control's <itemtemplate> )
> <script language="VB" runat="server">
> Public Sub checkforimg(ByVal Imagesubprod1 As String)
> If Imagesubprod1 <> "" then
> response.write(Imagesubprod1)
> Else
> response.write("nbsp;")
> End If
> End Sub
> </script>
> ... but I get an "Overload resolution failed because no accessible
> 'ToString' can be called with these arguments:" error when it comes
> time to check for the image as follows.
> <%# checkforimg(DataBinder.Eval(Container.DataItem,
> "Imagesubprod1"))%>
> When I form the header for the sub as follows:
> Public Sub checkforimg(ByVal Imagesubprod1 As String) As string
> ..i get an "Expected end of statement " error on this line
subroutines or functions wont work.
here's my code. PLEASE HELP!, what am i typing wrong??
<%@dotnet.itags.org. Page Language="VB" %>
<script runat="server"
' Insert page code here
'
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<%
Dim arrPrimeNos, arrNames
Sub subPrintArray(arrToPrint, iStartValue, iStopValue)
Dim iCounter
For iCounter = iStartValue to iStopValue
Response.Write(arrToPrint(iCounter))
Response.Write("<BR>")
Next
End Sub
arrPrimeNos=Array(2,3,5)
arrName=Array("John","Mary","Bolek")
'call subroutine
subPrintArray arrNames, 2, 3
%
</form>
</body>
</html>1. You'd better put the server side code in <script> tag if you use inline coding. Using <% %> is not a .net way.
2. You can only call a method (function, subrouting or event handler) from a method (function, subrouting or event handler), so your code need to change like this:
<%@. Page Language="VB" %>
<script runat="server"
Sub page_loadDim arrPrimeNos() As Integer = {2, 3, 5}
Dim arrNames() As String = {"John", "Mary", "Bolek"}'call subroutine
subPrintArray arrNames, 2, 3
End SubSub subPrintArray(arrToPrint, iStartValue, iStopValue)
Dim iCounter
For iCounter = iStartValue to iStopValue
Response.Write(arrToPrint(iCounter))
Response.Write("<BR>")
Next
End Sub</script>
<html>
<head>
</head>
<body>
<form runat="server">
</form>
</body>
</html>
thank you very much
Wednesday, March 28, 2012
Sudden Cookie problem is .aspx page
Cookie problem in .aspx application.
I have a cookie problem that makes no sense. I get this error when the page
loads:
Object reference not set to an instance of an object.
I am reading the cookie into a var with standard code.
Where the problem makes no sense is that this application sits on my
network, and all
other machines load the page fine. As has the page loaded on all machines
fine since the application
has been in development. Only now, there seems to be a problem.
The other machines are running XP Pro and Windows 2000 Pro, respectfully.
The machine that throws the error is running XP.
All machines have been updated regularly.
Does any know what in the world could be happening with the XP machine for
it never loads the cookie when the page is requested? (note, no privacy
changes have been made to the browser on the XP machine and the machine is
virus free)
Any help would be greatly appreciated.
Branton EllerbeePost your code please
--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"branton ellerbee" <blrb@.sbcglobal.net> wrote in message
news:3olOb.6716$kg1.1173@.newssvr24.news.prodigy.co m...
>
> Cookie problem in .aspx application.
> I have a cookie problem that makes no sense. I get this error when the
page
> loads:
> Object reference not set to an instance of an object.
> I am reading the cookie into a var with standard code.
> Where the problem makes no sense is that this application sits on my
> network, and all
> other machines load the page fine. As has the page loaded on all machines
> fine since the application
> has been in development. Only now, there seems to be a problem.
> The other machines are running XP Pro and Windows 2000 Pro, respectfully.
> The machine that throws the error is running XP.
> All machines have been updated regularly.
> Does any know what in the world could be happening with the XP machine for
> it never loads the cookie when the page is requested? (note, no privacy
> changes have been made to the browser on the XP machine and the machine is
> virus free)
> Any help would be greatly appreciated.
> Branton Ellerbee
Sudden VS2003 Error
my own machine. I had to reboot. When I came back, VS started acting
flakey. It would not reload my project claiming that it could not connect
to the url on my machine (something like http://localhost/myApplication).
"A connection with the server could not be established"
I tried this:
1) backed up all files
2) deleted the project folder from wwwroot
3) created a new web application in visual studio using the same name
4) copied all the source code files (no project or solution) into that
folder and added them to the new project
Worked fine at first and built just fine, but when I exited VS and came back
it would no longer load either.
Caveat 1: When I rebooted I changed my network password, but I don't expect
this should matter in any way.
Caveat 2: I am running McAfee Anti-Virus (required by the site whose machine
this actually is).
Tried to google the error for a solution, but nothing seems to fix it.
Any takers?Hi
There are known problems with McAfee and VS.NET.
If you are forced to use McAfee make sure the "buffer overload" option
is off.
Good luck.
Regards,
Daniel Roth
MCSD.NET
Dan,
I'll disable it, but can you tell me what effect it had on you, or how you
figured out that it was the problem?
<dan.c.roth@.gmail.com> wrote
> There are known problems with McAfee and VS.NET.
> If you are forced to use McAfee make sure the "buffer overload" option
> is off.
Sudden VS2003 Error
my own machine. I had to reboot. When I came back, VS started acting
flakey. It would not reload my project claiming that it could not connect
to the url on my machine (something like http://localhost/myApplication).
"A connection with the server could not be established"
I tried this:
1) backed up all files
2) deleted the project folder from wwwroot
3) created a new web application in visual studio using the same name
4) copied all the source code files (no project or solution) into that
folder and added them to the new project
Worked fine at first and built just fine, but when I exited VS and came back
it would no longer load either.
Caveat 1: When I rebooted I changed my network password, but I don't expect
this should matter in any way.
Caveat 2: I am running McAfee Anti-Virus (required by the site whose machine
this actually is).
Tried to google the error for a solution, but nothing seems to fix it.
Any takers?Hi
There are known problems with McAfee and VS.NET.
If you are forced to use McAfee make sure the "buffer overload" option
is off.
Good luck.
Regards,
Daniel Roth
MCSD.NET
Dan,
I'll disable it, but can you tell me what effect it had on you, or how you
figured out that it was the problem?
<dan.c.roth@.gmail.com> wrote
> There are known problems with McAfee and VS.NET.
> If you are forced to use McAfee make sure the "buffer overload" option
> is off.
Saturday, March 24, 2012
sugggestion
Anybody can tell me why I am getting this error while running ASP.NET Web Application. Before running some other same type of web form, I was not having any difficulty.
I am using virtual lab for "Developing Microsoft® ASP.NET Web Applications Using Visual Studio® .NET"
ruprety
Server Error in '/WebApplicationXML' Application. ('/WebApplicationXML' is Project name)
------------------------
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Could not load type 'WebApplicationXML.Global'.
Source Error:
Line 1: <%@dotnet.itags.org. Application Codebehind="Global.asax.vb" Inherits="WebApplicationXML.Global" %
Source File: c:\inetpub\wwwroot\WebApplicationXML\global.asax Line: 1
------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573Hi,
Usually it happens if application was not compiled successfully.
Thursday, March 22, 2012
SuppressUnmanagedCodeSecurity
When I try to compile, I get an error saying that the namespace is not
known.
Any ideas please ?
Michael Tissington
http://www.oaklodge.com
http://www.tabtag.comSeems odd, Michael. The following compiles fine, so I'm guessing some
other problem exists.
using System.Security;
[SuppressUnmanagedCodeSecurity]
public class NativeMethods
{
// ...
}
Scott
http://www.OdeToCode.com/blogs/scott/
On Sat, 3 Dec 2005 22:08:15 -0800, "Michael Tissington"
<mtissington@.newsgroups.nospam> wrote:
>I'm having trouble using the SuppressUnmanagedCodeSecurity attribute.
>When I try to compile, I get an error saying that the namespace is not
>known.
>Any ideas please ?
Hi Michael,
As for the "namespace not known..." error when you try using the
SuppressUnmanagedCodeSecurity Attribute , I think it may be caused by the
namespace of the SuppressUnmanagedCodeSecurity class is not imported in
your code file. Have you add the folloing line in your code file:
using System.Security;
or Imports System.Security for VB.NET
The SuppressUnmanagedCodeSecurity class is under the "System.Security
namespace" so we have to import the namspace if we don't specify the full
class name like:
System.Security.SuppressUnmanagedCodeSecurity
Thanks,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
| From: "Michael Tissington" <mtissington@.newsgroups.nospam>
| Subject: SuppressUnmanagedCodeSecurity
| Date: Sat, 3 Dec 2005 22:08:15 -0800
| Lines: 13
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| Message-ID: <e9i4ckJ#FHA.2176@.TK2MSFTNGP14.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 65.249.55.7
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:362561
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| I'm having trouble using the SuppressUnmanagedCodeSecurity attribute.
|
| When I try to compile, I get an error saying that the namespace is not
| known.
|
| Any ideas please ?
|
| --
| Michael Tissington
| http://www.oaklodge.com
| http://www.tabtag.com
|
|
|
Supress error/warning of winapi in class?
Warning 1 Access of shared member, constant member, enum member or nested
type through an instance; qualifying expression will not be evaluated...
This because i have a call in a win32 dll:
Public Declare Ansi Function TheCall Lib "MyDll.DLL" Alias "TheCall" (ByVal
szKey As String) As Int32
Option Explict or Strict don't do anything here.
I'm looking for a solution hopefully placed in the class itself if possible.
The call is executed through the dimensioned class var.
'you are referencing a static method from an instance rather than its class.
use ClassName.MethodName (class referenece), not myObj.MethodName (instance
reference)
-- bruce (sqlwork.com)
"Edwin Knoppert" <news@.hellobasic.com> wrote in message
news:439eef25$0$2339$ba620dc5@.text.nova.planet.nl...
>I have this error:
> Warning 1 Access of shared member, constant member, enum member or nested
> type through an instance; qualifying expression will not be evaluated...
> This because i have a call in a win32 dll:
> Public Declare Ansi Function TheCall Lib "MyDll.DLL" Alias "TheCall"
> (ByVal szKey As String) As Int32
> Option Explict or Strict don't do anything here.
> I'm looking for a solution hopefully placed in the class itself if
> possible.
> The call is executed through the dimensioned class var.
> '
>
Hey, thanks, thought the declares where not public, brain-dead of course.
It says: PUBLIC :)
To bad i couldn't reuse my WITH statement with these calls.
I swapped it for the dimmed object but MS does not like that :)
Thanks,
"Bruce Barker" <brubar_nospamplease_@.safeco.com> schreef in bericht
news:eMrI3rAAGHA.1268@.TK2MSFTNGP11.phx.gbl...
> you are referencing a static method from an instance rather than its
> class. use ClassName.MethodName (class referenece), not myObj.MethodName
> (instance reference)
> -- bruce (sqlwork.com)
>
> "Edwin Knoppert" <news@.hellobasic.com> wrote in message
> news:439eef25$0$2339$ba620dc5@.text.nova.planet.nl...
>
Tuesday, March 13, 2012
SURVEY: How are you doing Global Error Handling in ASP.NET
error handling in ASP.NET. Namely:
1. Derive all your pages from a custom Page class, and override
OnError()
2. Specify a custom 500 handler in Web.Config
3. Specify a custom 500 handler in IIS
and I guess you could add:
4. Let them fall through & spit out ugly error messages
I'm curious to see how people are doing it in the real world.
Personally, I've always used option #1, as it seems to offer the most
flexibility, and I'm already using custom Page objects, so it's no
extra work.
I'm asking this because we're getting close to a public BETA release
of Regressor.NET, and am considering adding support for cases 2 and
3. Before I commit the resources though, I'd like to get a feel for
how many people would benefit from it.
I look forward to seeing what people have to say. Thanks for the
help!
Jason Kester
Automated Crash Reporting and Regression Testing for ASP.NET
http://www.regressor.net/
ps. If anybody is interested in becoming a Beta tester for
Regressor.NET, let me know!Jason Kester schrieb:
Quote:
Originally Posted by
Best I can tell, there are three basic ways you can deal with global
error handling in ASP.NET. Namely:
>
1. Derive all your pages from a custom Page class, and override
OnError()
>
2. Specify a custom 500 handler in Web.Config
>
3. Specify a custom 500 handler in IIS
>
and I guess you could add:
>
4. Let them fall through & spit out ugly error messages
5. Use global.asax to catch errors
greets,
steve
--
Stefan Kalcher
Programming's just like sex, one mistake, you support it for life.
On Mar 12, 1:29 am, "Jason Kester" <jasonkes...@dotnet.itags.org.gmail.comwrote:
Quote:
Originally Posted by
Best I can tell, there are three basic ways you can deal with global
error handling in ASP.NET. Namely:
>
1. Derive all your pages from a custom Page class, and override
OnError()
>
2. Specify a custom 500 handler in Web.Config
>
3. Specify a custom 500 handler in IIS
>
and I guess you could add:
>
4. Let them fall through & spit out ugly error messages
>
I'm curious to see how people are doing it in the real world.
Personally, I've always used option #1, as it seems to offer the most
flexibility, and I'm already using custom Page objects, so it's no
extra work.
>
I'm asking this because we're getting close to a public BETA release
of Regressor.NET, and am considering adding support for cases 2 and
3. Before I commit the resources though, I'd like to get a feel for
how many people would benefit from it.
>
I look forward to seeing what people have to say. Thanks for the
help!
>
Jason Kester
Automated Crash Reporting and Regression Testing for ASP.NEThttp://www.regressor.net/
>
ps. If anybody is interested in becoming a Beta tester for
Regressor.NET, let me know!
In my application, I do the following:
1.) All of my Web forms derive from a base Page class. OnError is
overridden to handle errors there.
2.) I also handle exceptions in Global.asax, in the event that I've
missed something.
3.) Wherever the default handlers in my base class and/or Global.asax
aren't appropriate, I implement suitable exception handling.
4.) The application has a custom web page, which is itself an aspx
page. Some might have a tough time with that design, but it's
*extremely* stable, and doesn't do anything subject to failure.
5.) Every exception is logged to the database (if possible) and to the
Windows event log.
Yeah. I take 'em very seriously.
I'm also a big fan of the custom Page idea. And I agree that logging
everything is important (that's why we wrote Regressor.NET!) It's
amazing how much you find out about your application when every single
exception gets logged.
Curious though, how many exceptions are you really seeing fall through
to Global.asax? I've seen a few posts on this thread from people that
are using Global.asax as a backup, but personally I've never had a
problem with the overriden OnError in my custom page classes. At
least I've never seen anything fall through in person, but then I
guess I'd never know if anything were slipping through the cracks...
Mike, do you forward crash reports directly to your bug tracking
software?
Jason Kester
Automated Crash Reporting and Regression Testing for ASP.NET
http://www.regressor.net/
On Mar 12, 11:04 am, "Mike Hofer" <kchighl...@dotnet.itags.org.gmail.comwrote:
Quote:
Originally Posted by
In my application, I do the following:
>
1.) All of my Web forms derive from a base Page class. OnError is
overridden to handle errors there.
>
2.) I also handle exceptions in Global.asax, in the event that I've
missed something.
>
3.) Wherever the default handlers in my base class and/or Global.asax
aren't appropriate, I implement suitable exception handling.
>
4.) The application has a custom web page, which is itself an aspx
page. Some might have a tough time with that design, but it's
*extremely* stable, and doesn't do anything subject to failure.
>
5.) Every exception is logged to the database (if possible) and to the
Windows event log.
>
Yeah. I take 'em very seriously.- Hide quoted text -
>
- Show quoted text -
On Mar 12, 3:04 pm, "Jason Kester" <jasonkes...@dotnet.itags.org.gmail.comwrote:
Quote:
Originally Posted by
I'm also a big fan of the custom Page idea. And I agree that logging
everything is important (that's why we wrote Regressor.NET!) It's
amazing how much you find out about your application when every single
exception gets logged.
>
Curious though, how many exceptions are you really seeing fall through
to Global.asax? I've seen a few posts on this thread from people that
are using Global.asax as a backup, but personally I've never had a
problem with the overriden OnError in my custom page classes. At
least I've never seen anything fall through in person, but then I
guess I'd never know if anything were slipping through the cracks...
>
Mike, do you forward crash reports directly to your bug tracking
software?
>
Jason Kester
Automated Crash Reporting and Regression Testing for ASP.NEThttp://www.regressor.net/
>
On Mar 12, 11:04 am, "Mike Hofer" <kchighl...@dotnet.itags.org.gmail.comwrote:
>
>
>
Quote:
Originally Posted by
In my application, I do the following:
>
Quote:
Originally Posted by
1.) All of my Web forms derive from a base Page class. OnError is
overridden to handle errors there.
>
Quote:
Originally Posted by
2.) I also handle exceptions in Global.asax, in the event that I've
missed something.
>
Quote:
Originally Posted by
3.) Wherever the default handlers in my base class and/or Global.asax
aren't appropriate, I implement suitable exception handling.
>
Quote:
Originally Posted by
4.) The application has a custom web page, which is itself an aspx
page. Some might have a tough time with that design, but it's
*extremely* stable, and doesn't do anything subject to failure.
>
Quote:
Originally Posted by
5.) Every exception is logged to the database (if possible) and to the
Windows event log.
>
Quote:
Originally Posted by
Yeah. I take 'em very seriously.- Hide quoted text -
>
Quote:
Originally Posted by
- Show quoted text -- Hide quoted text -
>
- Show quoted text -
Unfortunately, no, but that's due to the disconnected nature of our
system. The bug tracking database is housed here, at the software
shop, and the software itself is located on the production server at
the client -- in a different state, on a secure system, behind a
firewall, and to which we have no access. We are not permitted any
access to that system, due to security concerns. (It's a government
agency.)
The database contains an error log table; we are fortunate enough to
be able to receive backups of the database for data mining purposes,
and we mine that table to monitor exceptions for stuff that we missed.
I'm pleased to report that our unhandled exception rate is *extremely*
low.
We use BugTracker.NET here to track defects. It's rudimentary, but it
gets the job done for what we need. If we were able to write a secure
Web service to shuffle the data across the wire to BugTracker, I would
definitely be interested in doing that, but I don't think the client
will approve that any time in the near future. (Money is always a big
concern, and they have other things they want to get done at this
point in time. Since we are doing things pretty well "status quo,"
they're likely going to take the point of view that we can survive as
we are until it becomes a truly pressing concern. And if it ever came
to that, it would speak volumes about my code quality--they'd likely
need to hire a new developer, and I'd be brushing off my resume.)
On Mar 12, 3:04 pm, "Jason Kester" <jasonkes...@dotnet.itags.org.gmail.comwrote:
Quote:
Originally Posted by
I'm also a big fan of the custom Page idea. And I agree that logging
everything is important (that's why we wrote Regressor.NET!) It's
amazing how much you find out about your application when every single
exception gets logged.
>
Curious though, how many exceptions are you really seeing fall through
to Global.asax? I've seen a few posts on this thread from people that
are using Global.asax as a backup, but personally I've never had a
problem with the overriden OnError in my custom page classes. At
least I've never seen anything fall through in person, but then I
guess I'd never know if anything were slipping through the cracks...
>
Mike, do you forward crash reports directly to your bug tracking
software?
>
Jason Kester
Automated Crash Reporting and Regression Testing for ASP.NEThttp://www.regressor.net/
>
On Mar 12, 11:04 am, "Mike Hofer" <kchighl...@dotnet.itags.org.gmail.comwrote:
>
>
>
Quote:
Originally Posted by
In my application, I do the following:
>
Quote:
Originally Posted by
1.) All of my Web forms derive from a base Page class. OnError is
overridden to handle errors there.
>
Quote:
Originally Posted by
2.) I also handle exceptions in Global.asax, in the event that I've
missed something.
>
Quote:
Originally Posted by
3.) Wherever the default handlers in my base class and/or Global.asax
aren't appropriate, I implement suitable exception handling.
>
Quote:
Originally Posted by
4.) The application has a custom web page, which is itself an aspx
page. Some might have a tough time with that design, but it's
*extremely* stable, and doesn't do anything subject to failure.
>
Quote:
Originally Posted by
5.) Every exception is logged to the database (if possible) and to the
Windows event log.
>
Quote:
Originally Posted by
Yeah. I take 'em very seriously.- Hide quoted text -
>
Quote:
Originally Posted by
- Show quoted text -- Hide quoted text -
>
- Show quoted text -
In regards to your questions regarding exceptions that fall through to
global.asax, I've only seen this a handful of times at best. But when
they did, I was *very* thankful it was there. Since we log everything
to our database, data mining helps us to uncover those unhandled
exceptions and treat them as critical defects that require immediate
resolution.
Yeah, it's tough having to work in the real world. Best practices
have a way of slipping through the cracks at most places.
Here at Expat Software we use Fogbugz, so we have the option of
sending out crash report distress calls either by Email or via HTTP.
Either way, Fogbugz will automatically log a new case for us.
Regardless, it sounds like you're well ahead of the game. I suspect
that most shops have never considered logging exceptions at all!
Jason Kester
Automated Crash Reporting and Regression Testing for ASP.NET
http://www.regressor.net/
On Mar 12, 12:14 pm, "Mike Hofer" <kchighl...@dotnet.itags.org.gmail.comwrote:
Quote:
Originally Posted by
>
Unfortunately, no, but that's due to the disconnected nature of our
system. The bug tracking database is housed here, at the software
shop, and the software itself is located on the production server at
the client -- in a different state, on a secure system, behind a
firewall, and to which we have no access. We are not permitted any
access to that system, due to security concerns. (It's a government
agency.)
>
Yeah, it's tough having to work in the real world. Best practices
have a way of slipping through the cracks at most places.
Here at Expat Software we use Fogbugz, so we have the option of
sending out crash report distress calls either by Email or via HTTP.
Either way, Fogbugz will automatically log a new case for us.
Regardless, it sounds like you're well ahead of the game. I suspect
that most shops have never considered logging exceptions at all!
Jason Kester
Automated Crash Reporting and Regression Testing for ASP.NET
http://www.regressor.net/
On Mar 12, 12:14 pm, "Mike Hofer" <kchighl...@dotnet.itags.org.gmail.comwrote:
Quote:
Originally Posted by
>
Unfortunately, no, but that's due to the disconnected nature of our
system. The bug tracking database is housed here, at the software
shop, and the software itself is located on the production server at
the client -- in a different state, on a secure system, behind a
firewall, and to which we have no access. We are not permitted any
access to that system, due to security concerns. (It's a government
agency.)
>
SURVEY: How are you doing Global Error Handling in ASP.NET
error handling in ASP.NET. Namely:
1. Derive all your pages from a custom Page class, and override
OnError()
2. Specify a custom 500 handler in Web.Config
3. Specify a custom 500 handler in IIS
and I guess you could add:
4. Let them fall through & spit out ugly error messages
I'm curious to see how people are doing it in the real world.
Personally, I've always used option #1, as it seems to offer the most
flexibility, and I'm already using custom Page objects, so it's no
extra work.
I'm asking this because we're getting close to a public BETA release
of Regressor.NET, and am considering adding support for cases 2 and
3. Before I commit the resources though, I'd like to get a feel for
how many people would benefit from it.
I look forward to seeing what people have to say. Thanks for the
help!
Jason Kester
Automated Crash Reporting and Regression Testing for ASP.NET
http://www.regressor.net/
ps. If anybody is interested in becoming a Beta tester for
Regressor.NET, let me know!Jason Kester schrieb:
> Best I can tell, there are three basic ways you can deal with global
> error handling in ASP.NET. Namely:
> 1. Derive all your pages from a custom Page class, and override
> OnError()
> 2. Specify a custom 500 handler in Web.Config
> 3. Specify a custom 500 handler in IIS
> and I guess you could add:
> 4. Let them fall through & spit out ugly error messages
5. Use global.asax to catch errors
greets,
steve
Stefan Kalcher
Programming's just like sex, one mistake, you support it for life.
On Mar 12, 1:29 am, "Jason Kester" <jasonkes...@.gmail.com> wrote:
> Best I can tell, there are three basic ways you can deal with global
> error handling in ASP.NET. Namely:
> 1. Derive all your pages from a custom Page class, and override
> OnError()
> 2. Specify a custom 500 handler in Web.Config
> 3. Specify a custom 500 handler in IIS
> and I guess you could add:
> 4. Let them fall through & spit out ugly error messages
> I'm curious to see how people are doing it in the real world.
> Personally, I've always used option #1, as it seems to offer the most
> flexibility, and I'm already using custom Page objects, so it's no
> extra work.
> I'm asking this because we're getting close to a public BETA release
> of Regressor.NET, and am considering adding support for cases 2 and
> 3. Before I commit the resources though, I'd like to get a feel for
> how many people would benefit from it.
> I look forward to seeing what people have to say. Thanks for the
> help!
> Jason Kester
> Automated Crash Reporting and Regression Testing for ASP.NEThttp://www.reg
ressor.net/
> ps. If anybody is interested in becoming a Beta tester for
> Regressor.NET, let me know!
In my application, I do the following:
1.) All of my Web forms derive from a base Page class. OnError is
overridden to handle errors there.
2.) I also handle exceptions in Global.asax, in the event that I've
missed something.
3.) Wherever the default handlers in my base class and/or Global.asax
aren't appropriate, I implement suitable exception handling.
4.) The application has a custom web page, which is itself an aspx
page. Some might have a tough time with that design, but it's
*extremely* stable, and doesn't do anything subject to failure.
5.) Every exception is logged to the database (if possible) and to the
Windows event log.
Yeah. I take 'em very seriously.
I'm also a big fan of the custom Page idea. And I agree that logging
everything is important (that's why we wrote Regressor.NET!) It's
amazing how much you find out about your application when every single
exception gets logged.
Curious though, how many exceptions are you really seeing fall through
to Global.asax? I've seen a few posts on this thread from people that
are using Global.asax as a backup, but personally I've never had a
problem with the overriden OnError in my custom page classes. At
least I've never seen anything fall through in person, but then I
guess I'd never know if anything were slipping through the cracks...
Mike, do you forward crash reports directly to your bug tracking
software?
Jason Kester
Automated Crash Reporting and Regression Testing for ASP.NET
http://www.regressor.net/
On Mar 12, 11:04 am, "Mike Hofer" <kchighl...@.gmail.com> wrote:
> In my application, I do the following:
> 1.) All of my Web forms derive from a base Page class. OnError is
> overridden to handle errors there.
> 2.) I also handle exceptions in Global.asax, in the event that I've
> missed something.
> 3.) Wherever the default handlers in my base class and/or Global.asax
> aren't appropriate, I implement suitable exception handling.
> 4.) The application has a custom web page, which is itself an aspx
> page. Some might have a tough time with that design, but it's
> *extremely* stable, and doesn't do anything subject to failure.
> 5.) Every exception is logged to the database (if possible) and to the
> Windows event log.
> Yeah. I take 'em very seriously.- Hide quoted text -
> - Show quoted text -
On Mar 12, 3:04 pm, "Jason Kester" <jasonkes...@.gmail.com> wrote:
> I'm also a big fan of the custom Page idea. And I agree that logging
> everything is important (that's why we wrote Regressor.NET!) It's
> amazing how much you find out about your application when every single
> exception gets logged.
> Curious though, how many exceptions are you really seeing fall through
> to Global.asax? I've seen a few posts on this thread from people that
> are using Global.asax as a backup, but personally I've never had a
> problem with the overriden OnError in my custom page classes. At
> least I've never seen anything fall through in person, but then I
> guess I'd never know if anything were slipping through the cracks...
> Mike, do you forward crash reports directly to your bug tracking
> software?
> Jason Kester
> Automated Crash Reporting and Regression Testing for ASP.NEThttp://www.reg
ressor.net/
> On Mar 12, 11:04 am, "Mike Hofer" <kchighl...@.gmail.com> wrote:
>
>
>
>
>
>
>
>
>
> - Show quoted text -
Unfortunately, no, but that's due to the disconnected nature of our
system. The bug tracking database is housed here, at the software
shop, and the software itself is located on the production server at
the client -- in a different state, on a secure system, behind a
firewall, and to which we have no access. We are not permitted any
access to that system, due to security concerns. (It's a government
agency.)
The database contains an error log table; we are fortunate enough to
be able to receive backups of the database for data mining purposes,
and we mine that table to monitor exceptions for stuff that we missed.
I'm pleased to report that our unhandled exception rate is *extremely*
low.
We use BugTracker.NET here to track defects. It's rudimentary, but it
gets the job done for what we need. If we were able to write a secure
Web service to shuffle the data across the wire to BugTracker, I would
definitely be interested in doing that, but I don't think the client
will approve that any time in the near future. (Money is always a big
concern, and they have other things they want to get done at this
point in time. Since we are doing things pretty well "status quo,"
they're likely going to take the point of view that we can survive as
we are until it becomes a truly pressing concern. And if it ever came
to that, it would speak volumes about my code quality--they'd likely
need to hire a new developer, and I'd be brushing off my resume.)
On Mar 12, 3:04 pm, "Jason Kester" <jasonkes...@.gmail.com> wrote:
> I'm also a big fan of the custom Page idea. And I agree that logging
> everything is important (that's why we wrote Regressor.NET!) It's
> amazing how much you find out about your application when every single
> exception gets logged.
> Curious though, how many exceptions are you really seeing fall through
> to Global.asax? I've seen a few posts on this thread from people that
> are using Global.asax as a backup, but personally I've never had a
> problem with the overriden OnError in my custom page classes. At
> least I've never seen anything fall through in person, but then I
> guess I'd never know if anything were slipping through the cracks...
> Mike, do you forward crash reports directly to your bug tracking
> software?
> Jason Kester
> Automated Crash Reporting and Regression Testing for ASP.NEThttp://www.reg
ressor.net/
> On Mar 12, 11:04 am, "Mike Hofer" <kchighl...@.gmail.com> wrote:
>
>
>
>
>
>
>
>
>
> - Show quoted text -
In regards to your questions regarding exceptions that fall through to
global.asax, I've only seen this a handful of times at best. But when
they did, I was *very* thankful it was there. Since we log everything
to our database, data mining helps us to uncover those unhandled
exceptions and treat them as critical defects that require immediate
resolution.
Yeah, it's tough having to work in the real world. Best practices
have a way of slipping through the cracks at most places.
Here at Expat Software we use Fogbugz, so we have the option of
sending out crash report distress calls either by Email or via HTTP.
Either way, Fogbugz will automatically log a new case for us.
Regardless, it sounds like you're well ahead of the game. I suspect
that most shops have never considered logging exceptions at all!
Jason Kester
Automated Crash Reporting and Regression Testing for ASP.NET
http://www.regressor.net/
On Mar 12, 12:14 pm, "Mike Hofer" <kchighl...@.gmail.com> wrote:
> Unfortunately, no, but that's due to the disconnected nature of our
> system. The bug tracking database is housed here, at the software
> shop, and the software itself is located on the production server at
> the client -- in a different state, on a secure system, behind a
> firewall, and to which we have no access. We are not permitted any
> access to that system, due to security concerns. (It's a government
> agency.)
>
Yeah, it's tough having to work in the real world. Best practices
have a way of slipping through the cracks at most places.
Here at Expat Software we use Fogbugz, so we have the option of
sending out crash report distress calls either by Email or via HTTP.
Either way, Fogbugz will automatically log a new case for us.
Regardless, it sounds like you're well ahead of the game. I suspect
that most shops have never considered logging exceptions at all!
Jason Kester
Automated Crash Reporting and Regression Testing for ASP.NET
http://www.regressor.net/
On Mar 12, 12:14 pm, "Mike Hofer" <kchighl...@.gmail.com> wrote:
> Unfortunately, no, but that's due to the disconnected nature of our
> system. The bug tracking database is housed here, at the software
> shop, and the software itself is located on the production server at
> the client -- in a different state, on a secure system, behind a
> firewall, and to which we have no access. We are not permitted any
> access to that system, due to security concerns. (It's a government
> agency.)
>
Suspect error using RichTextBox Class in server code
RichTextBox Class in our server code to manipulate RTF that is stored
in the database. To clarify, we are not using or attempting to use
this class in the aspx page that calls the code, nor is the 'using
System.Windows.Forms' referenced in any of the aspx pages. The first
client using this software has been experiencing an error that we
cannot reproduce in-house. The error occurs intermittently anywhere
after 2-4 days of use, so it is not something reproducible on demand.
The fix is to restart IIS and on a couple of occasions a restart of
the server was necessary. The error is being trapped in code and
returned as string to the user which displays on the aspx page so it
is not an unhandled exception with a dump of the stack trace. The
error message is 'Error creating window handle". Once one user
receives this error all users receive the same error when trying to
perform the same operation. I am not 100% sure that the RichTextBox
code is what is causing the error but based on the message involved it
is my best guess. Here is a code snipit that shows how we are using
the RichTextBox.
string strFreeRTF = drRow["FRTF"].ToString().Trim();
string strTempRTF = drRow["TMPLTRTF"].ToString().Trim();
RichTextBox rtfFree = new RichTextBox();
rtfFree.Rtf = strFreeRTF; //prevents null reference
RichTextBox rtfTemp = new RichTextBox();
rtfTemp.Rtf = strTempRTF;
if(rtfTemp.Text.Length > 0)
{
rtfFree.AppendText("\r\n");
rtfTemp.SelectAll();
rtfTemp.Copy();
rtfFree.Paste();
}
if(strCodedCharting.Length > 0)
{
rtfFree.AppendText("\r\n");
rtfFree.AppendText(strCodedCharting);
}
if(drChart["SUMMARY"].ToString() != "")
{
if(rtfFree.Text.Length > 0)
{
rtfFree.AppendText("\r\n");
}
rtfFree.AppendText(drRow["SMRYTXT"].ToString());
}
if(rtfFree.Text != "")
strRet = rtfFree.Rtf;
return strRet;
The code performs what it is designed to do but obviously we need to
track down why the error occurs.
Does anyone have information that might assist with troubleshooting
this problem. Thanksusing winform controls are not supported by aspx pages. they require a
window handle to perform correctly, and system services like iis and
asp.net, do not have permission to create a window handle as they need
access to the desktop.
you might get away with it if the console is alway logged on the server, and
you gave permission. you still run the risk, that if the control pop's up a
dialog box (say for en error), your asp.net thread will be blocked until
some goes to the console and responds to the dialogbox.
this is very poor design, and you should look at replacing the rtf control
as soon as possible.
-- bruce (sqlwork.com)
"Eric" <msdnsupport@.nospammediserve.com> wrote in message
news:3fc3df27.1150041703@.news.devexpress.com...
> Using the 1.1 framework. We are using a newly created instance of a
> RichTextBox Class in our server code to manipulate RTF that is stored
> in the database. To clarify, we are not using or attempting to use
> this class in the aspx page that calls the code, nor is the 'using
> System.Windows.Forms' referenced in any of the aspx pages. The first
> client using this software has been experiencing an error that we
> cannot reproduce in-house. The error occurs intermittently anywhere
> after 2-4 days of use, so it is not something reproducible on demand.
> The fix is to restart IIS and on a couple of occasions a restart of
> the server was necessary. The error is being trapped in code and
> returned as string to the user which displays on the aspx page so it
> is not an unhandled exception with a dump of the stack trace. The
> error message is 'Error creating window handle". Once one user
> receives this error all users receive the same error when trying to
> perform the same operation. I am not 100% sure that the RichTextBox
> code is what is causing the error but based on the message involved it
> is my best guess. Here is a code snipit that shows how we are using
> the RichTextBox.
>
> string strFreeRTF = drRow["FRTF"].ToString().Trim();
> string strTempRTF = drRow["TMPLTRTF"].ToString().Trim();
> RichTextBox rtfFree = new RichTextBox();
> rtfFree.Rtf = strFreeRTF; //prevents null reference
> RichTextBox rtfTemp = new RichTextBox();
> rtfTemp.Rtf = strTempRTF;
> if(rtfTemp.Text.Length > 0)
> {
> rtfFree.AppendText("\r\n");
> rtfTemp.SelectAll();
> rtfTemp.Copy();
> rtfFree.Paste();
> }
> if(strCodedCharting.Length > 0)
> {
> rtfFree.AppendText("\r\n");
> rtfFree.AppendText(strCodedCharting);
> }
> if(drChart["SUMMARY"].ToString() != "")
> {
> if(rtfFree.Text.Length > 0)
> {
> rtfFree.AppendText("\r\n");
> }
> rtfFree.AppendText(drRow["SMRYTXT"].ToString());
> }
> if(rtfFree.Text != "")
> strRet = rtfFree.Rtf;
> return strRet;
> The code performs what it is designed to do but obviously we need to
> track down why the error occurs.
> Does anyone have information that might assist with troubleshooting
> this problem. Thanks
Switch / case statements
Error I'm getting is...
Control cannot fall through from one case label ('case 14:') to another
Well, not just case 14, but all of them.
Here's the sample...
publicbool checkMe(ArrayList myArray,int myInt){
switch (myInt) {
case 3 :
if(System.Convert.ToInt32( myArray[0] )== 0 &&
System.Convert.ToInt32( myArray[1]) == 1 )
{
myArray[1] = 0;
myArray[3] = 0;
myArray[0] = 1;
pNum = 3;
tempAL = myArray;
printArray(tempAL);
bSuccess =true;
break;
}
if( System.Convert.ToInt32( myArray[5] ) == 0 &&
System.Convert.ToInt32( myArray[4] ) == 1 )
{
myArray[4] = 0;
myArray[3] = 0;
myArray[5] = 1;
pNum = 3;
tempAL = myArray;
printArray(tempAL);
bSuccess =true;
break;
}
case 5 :
if( System.Convert.ToInt32( myArray[0] ) == 0 &&
System.Convert.ToInt32( myArray[2] ) == 1 )
{
myArray[2] = 0;
myArray[5] = 0;
myArray[0] = 1;
pNum = 5;
tempAL = myArray;
printArray(tempAL);
bSuccess =true;
break;
}
if( System.Convert.ToInt32( myArray[3] ) == 0 &&
System.Convert.ToInt32( myArray[4] ) == 1 )
{
myArray[4] = 0;
myArray[5] = 0;
myArray[3] = 1;
pNum = 5;
tempAL = myArray;
printArray(tempAL);
bSuccess =true;
break;
}
default :
{
bSuccess =false;
}
}
So, what's the deal?
Thanks,
Zath
That's because C# requires a break statement after every case statement (at least ones with code in them), and yours are within conditionals. Here's your code fixed up:
public bool checkMe(ArrayList myArray, int myInt)
{
switch ( myInt )
{
case 3:
if ( System.Convert.ToInt32(myArray[0]) == 0 &&
System.Convert.ToInt32(myArray[1]) == 1 )
{
myArray[1] = 0;
myArray[3] = 0;
myArray[0] = 1;
pNum = 3;
tempAL = myArray;
printArray(tempAL);
bSuccess = true;
break;
}
if ( System.Convert.ToInt32(myArray[5]) == 0 &&
System.Convert.ToInt32(myArray[4]) == 1 )
{
myArray[4] = 0;
myArray[3] = 0;
myArray[5] = 1;
pNum = 3;
tempAL = myArray;
printArray(tempAL);
bSuccess = true;
break;
}
break;
case 5:
if ( System.Convert.ToInt32(myArray[0]) == 0 &&
System.Convert.ToInt32(myArray[2]) == 1 )
{
myArray[2] = 0;
myArray[5] = 0;
myArray[0] = 1;
pNum = 5;
tempAL = myArray;
printArray(tempAL);
bSuccess = true;
break;
}
if ( System.Convert.ToInt32(myArray[3]) == 0 &&
System.Convert.ToInt32(myArray[4]) == 1 )
{
myArray[4] = 0;
myArray[5] = 0;
myArray[3] = 1;
pNum = 5;
tempAL = myArray;
printArray(tempAL);
bSuccess = true;
break;
}
break;
default :
bSuccess = false;
break;
} // end of switch statement
} // end of method
You could do something like this and it would work:
switch ( someValue )
{
case 0:
case 1:
// do something
break;
case 2:
// do something
break;
default:
break;
}
NC...
Thanks, that did the trick.
Just when you think you know all the syntax
Zath
Switch case (C#)
How can a use a expression like (percent_ < 25) into the switch case?
It's returning me a error.
switch (percent_) {case(percent_ < 25): img.ImageUrl ="~/img/BarraHorizGreen.gif";break;case(percent_ > 40): img.ImageUrl ="~/img/BarraHorizRed.gif";break;default: img.ImageUrl ="~/img/BarraHorizYellow.gif"; }
Sorry, C# does not support fall-through cases, each case must be exact. ref:http://msdn2.microsoft.com/EN-US/library/aa664749(VS.71).aspx
Work around is easy, use if...else statement.
in VB it would be possible like..
Select Case XCase 126 to 500' any number between 126 and 500Case 5, 9, 125' 5 or 9 or 125Case is > 800' any number greater than 800Case Else'End Select
but i think it would nt be possible in C#.. you can use Else..IF Ladder..
hope it helps./.
switch case with enum
i am getting "a constant value is required" error when i use the enum value
in case statement/
Any ideas?
sample code:
myconfig.cs
----
public enum WebHostingTypes
{
[Description("BASIC")] Basic,
[Description("PLUS")] Plus,
[Description("PREM")] Premium
}
product.cs
------
switch(WebHostingType)
{
case objCommon.GetEnumValueDescription(myconfig.WebHost ingTypes.Basic):
break;
case ....
}
----------
Even if i tried using a something like
public enum Volume
{
Low,
Medium,
High
}
string myVolume = "Medium";
switch(myVolume)
{
case myconfig.Volume.Medium:
break;
case ....
}
- GaneEnumerated values are numbers. If you treat them as such you will have no
problems with them.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
"gane kol" <ganekol@.softca.com> wrote in message
news:OY%23kHOlUFHA.1404@.TK2MSFTNGP09.phx.gbl...
> Hi
> i am getting "a constant value is required" error when i use the enum
> value
> in case statement/
> Any ideas?
> sample code:
> myconfig.cs
> ----
> public enum WebHostingTypes
> {
> [Description("BASIC")] Basic,
> [Description("PLUS")] Plus,
> [Description("PREM")] Premium
> }
> product.cs
> ------
> switch(WebHostingType)
> {
> case objCommon.GetEnumValueDescription(myconfig.WebHost ingTypes.Basic):
> break;
> case ....
> }
> ----------
> Even if i tried using a something like
> public enum Volume
> {
> Low,
> Medium,
> High
> }
> string myVolume = "Medium";
> switch(myVolume)
> {
> case myconfig.Volume.Medium:
> break;
> case ....
> }
> - Gane
well, ok. But i couldnt figure why the example below (2nd Example) is not
working for me, but worked for others (found in some tech articles).
"Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
news:eq2zl2lUFHA.3596@.TK2MSFTNGP14.phx.gbl...
> Enumerated values are numbers. If you treat them as such you will have no
> problems with them.
> --
> HTH,
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> What You Seek Is What You Get.
> "gane kol" <ganekol@.softca.com> wrote in message
> news:OY%23kHOlUFHA.1404@.TK2MSFTNGP09.phx.gbl...
> > Hi
> > i am getting "a constant value is required" error when i use the enum
> > value
> > in case statement/
> > Any ideas?
> > sample code:
> > myconfig.cs
> > ----
> > public enum WebHostingTypes
> > {
> > [Description("BASIC")] Basic,
> > [Description("PLUS")] Plus,
> > [Description("PREM")] Premium
> > }
> > product.cs
> > ------
> > switch(WebHostingType)
> > {
> > case objCommon.GetEnumValueDescription(myconfig.WebHost ingTypes.Basic):
> > break;
> > case ....
> > }
> > ----------
*********************** 2ND EXAMPLE
> > Even if i tried using a something like
> > public enum Volume
> > {
> > Low,
> > Medium,
> > High
> > }
> > string myVolume = "Medium";
> > switch(myVolume)
> > {
> > case myconfig.Volume.Medium:
> > break;
> > case ....
> > }
> > - Gane
> well, ok. But i couldnt figure why the example below (2nd Example) is not
> working for me, but worked for others (found in some tech articles).
I wouldn't know, as I haven't seen them. However, I can't see any good
reason for doing so. You have to be careful what tech articles you read, and
by whom they are written.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
"gane kol" <ganekol@.softca.com> wrote in message
news:umQZaHmUFHA.3280@.TK2MSFTNGP10.phx.gbl...
> well, ok. But i couldnt figure why the example below (2nd Example) is not
> working for me, but worked for others (found in some tech articles).
>
> "Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
> news:eq2zl2lUFHA.3596@.TK2MSFTNGP14.phx.gbl...
>> Enumerated values are numbers. If you treat them as such you will have no
>> problems with them.
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> .Net Developer
>> What You Seek Is What You Get.
>>
>> "gane kol" <ganekol@.softca.com> wrote in message
>> news:OY%23kHOlUFHA.1404@.TK2MSFTNGP09.phx.gbl...
>> > Hi
>>> > i am getting "a constant value is required" error when i use the enum
>> > value
>> > in case statement/
>> > Any ideas?
>>> > sample code:
>>> > myconfig.cs
>> > ----
>> > public enum WebHostingTypes
>> > {
>>> > [Description("BASIC")] Basic,
>>> > [Description("PLUS")] Plus,
>>> > [Description("PREM")] Premium
>>> > }
>>> > product.cs
>> > ------
>>> > switch(WebHostingType)
>>> > {
>>> > case objCommon.GetEnumValueDescription(myconfig.WebHost ingTypes.Basic):
>> > break;
>>> > case ....
>>> > }
>>> > ----------
>>
>
> *********************** 2ND EXAMPLE
>> > Even if i tried using a something like
>>> > public enum Volume
>>> > {
>>> > Low,
>>> > Medium,
>>> > High
>>> > }
>>> > string myVolume = "Medium";
>>> > switch(myVolume)
>>> > {
>>> > case myconfig.Volume.Medium:
>> > break;
>>> > case ....
>>> > }
>>> > - Gane
>>>>
>>
switch case with enum
i am getting "a constant value is required" error when i use the enum value
in case statement/
Any ideas?
sample code:
myconfig.cs
--
public enum WebHostingTypes
{
[Description("BASIC")] Basic,
[Description("PLUS")] Plus,
[Description("PREM")] Premium
}
product.cs
--
switch(WebHostingType)
{
case objCommon.GetEnumValueDescription(myconfig.WebHostingTypes.Basic):
break;
case ....
}
Even if i tried using a something like
public enum Volume
{
Low,
Medium,
High
}
string myVolume = "Medium";
switch(myVolume)
{
case myconfig.Volume.Medium:
break;
case ....
}
- GaneEnumerated values are numbers. If you treat them as such you will have no
problems with them.
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
What You S

"gane kol" <ganekol@.softca.com> wrote in message
news:OY%23kHOlUFHA.1404@.TK2MSFTNGP09.phx.gbl...
> Hi
> i am getting "a constant value is required" error when i use the enum
> value
> in case statement/
> Any ideas?
> sample code:
> myconfig.cs
> --
> public enum WebHostingTypes
> {
> [Description("BASIC")] Basic,
> [Description("PLUS")] Plus,
> [Description("PREM")] Premium
> }
> product.cs
> --
> switch(WebHostingType)
> {
> case objCommon.GetEnumValueDescription(myconfig.WebHostingTypes.Basic):
> break;
> case ....
> }
> --
> Even if i tried using a something like
> public enum Volume
> {
> Low,
> Medium,
> High
> }
> string myVolume = "Medium";
> switch(myVolume)
> {
> case myconfig.Volume.Medium:
> break;
> case ....
> }
> - Gane
>
well, ok. But i couldnt figure why the example below (2nd Example) is not
working for me, but worked for others (found in some tech articles).
"Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
news:eq2zl2lUFHA.3596@.TK2MSFTNGP14.phx.gbl...
> Enumerated values are numbers. If you treat them as such you will have no
> problems with them.
> --
> HTH,
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> What You S

> "gane kol" <ganekol@.softca.com> wrote in message
> news:OY%23kHOlUFHA.1404@.TK2MSFTNGP09.phx.gbl...
*********************** 2ND EXAMPLE
>
> well, ok. But i couldnt figure why the example below (2nd Example) is not
> working for me, but worked for others (found in some tech articles).
I wouldn't know, as I haven't seen them. However, I can't see any good
reason for doing so. You have to be careful what tech articles you read, and
by whom they are written.
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
What You S

"gane kol" <ganekol@.softca.com> wrote in message
news:umQZaHmUFHA.3280@.TK2MSFTNGP10.phx.gbl...
> well, ok. But i couldnt figure why the example below (2nd Example) is not
> working for me, but worked for others (found in some tech articles).
>
> "Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
> news:eq2zl2lUFHA.3596@.TK2MSFTNGP14.phx.gbl...
>
>
> *********************** 2ND EXAMPLE
>
>
Switch from ASPNET/NETWORK SERVICE Account
I have a page which requests info from a number of machines and whenever I try to do this I get an 'access is denied' error message. How do I change the account that my page is using to one which actually has access to the machines.
Thanksthere is not really a straight-forward answer to this.
if all of these servers are on the same domain, then you will ba able to impersoninate a common user in the web.config ..
<identity impersonate="true" userName="domain_name\user" password="password"/
make sure this user has the appropiate permissions on all the folders your are trying to access.
by default, the ASP.NET Machine Account is used for all requests.
psi
thanks psi
see if the framework and/or the ASP.NET Machine Account is on all machines ... if it is, and all the servers are on the same domain, you should be able to set the service to network service ...
psi
Is there any other way I could do this? There is a single account on the domain that I can use but its password is changed frequently and it is a account which my boss would prefer not to have hard-coded into the web.config file.
Thanks again,
Tomas
switch statement error?
I have the following code in index.aspx
<script runat="server">
switch(Request.QueryString["page"]) {
case "products":
masterForm.Controls.Add(LoadControl("products.ascx"));
break;
}
</script
masterForm is the id of the form tag in index.aspx
I am basically trying to dynamically include each section and use index.aspx as the master template file.
Here's the error:
Compiler Error Message: CS1519: Invalid token 'switch' in class, struct, or interface member declaration
It's stopping on the line with the switch statement.
What am I doing wrong?what is "page" in the following code
switch(Request.QueryString["page"])
page is supposed to be coming from:
index.aspx?page=products
ok I think the problem is that you are declaring switch in the HTML View. You need to run this code in the code behind file where all the Page_Load and Page_Init methods are. I hope you understand what I am trying to say.
Thanks, that did it!
<script runat="server">
void Page_Load() {
switch(Request.QueryString["page"]) {
case "products":
masterForm.Controls.Add(LoadControl("products.ascx"));
break;
}
}
</script>
Mohammed, WebMatrix doesn't permit the use of CodeBehind.
grizjr, you need to place the switch in the Page_Load method. For example:
void Page_Load(Object Sender, EventArgs E) {Obviously you've decided against my suggestion of simplifying your code.switch (...) {
...
}
}
The code is not working properly.
<script runat="server">
void Page_Load() {
switch(Request.QueryString["page"]) {
case "products":
masterForm.Controls.Add(LoadControl("products.ascx"));
break;
}
}
</script>
When I try and run it: I get this message:
Active Server Pages-Error 'ASP 0124'
Missing Language attribute
/nbhs/control-panel/switch.asp, line 2
The required Language attribute of the script tag is missing.
Active Server Pages-Error 'ASP 0124'
What tag is it missing?
Now that problem is fixed with this line of code:
<script language="vbscript" runat="server">
I just needed to add language="vbscript"
now I get another problem
This is the code that I have:
<script language="vbscript" runat="server">
void Page_Load(Object Sender, EventArgs E) {
switch(Request.QueryString["page"]) {
case "products":
masterForm.Controls.Add(LoadControl("products.ascx"));
break;
}
}
</script>
The error that I get is this:
Microsoft VBScript compilation error-Error '800a03ee'
Expected ')'
/nbhs/control-panel/switch.asp, line 5
void Page_Load(Object Sender, EventArgs E) {--------^
How can I fix this?