Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 197799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:53:02+00:00 2026-05-11T16:53:02+00:00

I’m building an ASP.NET 3.5 application and would like to expose an enum I

  • 0

I’m building an ASP.NET 3.5 application and would like to expose an enum I have in my WebService class without using it as a parameter in once of my WebMethods.

I have a really simple example to illustrate what I want… Let’s say I have the following WebService (I’ll call it Agent.asmx):

<System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class Agent
    Inherits System.Web.Services.WebService

<WebMethod(EnableSession:=True)> _
Public Function DoSomething(ByVal doWhat As WhatEnum) As Boolean
    Return ...
End Function

End Class

Public Enum WhatEnum
    AskStackOverflowQuestion
    PhoneAFriend
    FiftyFifty
End Enum

Because I used the Enum in one of the WebMethods, it will output the following in the JavaScript in generates for the Agent when the WebService is referenced in my .aspx page (from http://localhost/Agent.asmx/js):

if (typeof(SomeNamespace.WhatEnum) === 'undefined') {
    SomeNamespace.WhatEnum = function() { throw Error.invalidOperation(); }
    SomeNamespace.WhatEnum.prototype = { AskStackOverflowQuestion: 0,PhoneAFriend: 1,FiftyFifty: 2}
    SomeNamespace.WhatEnum.registerEnum('SomeNamespace.WhatEnum', true);
}

Now I can go and use these enums wherever I want on the client side. Now, that’s all fine and dandy, but I have another Enum in my Agent that I don’t actually use in any of the WebMethods, which I would also like to be automatically exposed in the Agent’s JavaScript. Is there a way, perhaps an attribute or something I could use, to cause it to be included?

If not, my fallback solution is to just create a dummy method with my Enum as a parameter so that it will be available, and simply never call it from the JS, though I’d rather not litter the code. Thanks!

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T16:53:02+00:00Added an answer on May 11, 2026 at 4:53 pm

    Obviously the easiest solution would be to create the dummy method. I guess I am wondering why you need an enumeration from your web service to be available in your JavaScript if you never pass that enumeration to the service or receive it from the service in any way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.