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 888293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:22:25+00:00 2026-05-15T13:22:25+00:00

In my .aspx I’ve got the following javascript variable defined: var action = <%=ProdView

  • 0

In my .aspx I’ve got the following javascript variable defined:

var action = <%=ProdView %>

In code-behind this returns a custom enum value:

protected ProductView ProdView { get; private set; }

I would figure that this would automatically be converted to a string in javascript? Looks like no because I get the runtime error “Item is not defined” where Item is the value ProdView.Item. Ultimately I want the action’s value to be “Item” as the value.

Here’s the Enum:

  public enum ProductView
  {
   Product,
   Item
  }
  • 1 1 Answer
  • 0 Views
  • 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-15T13:22:26+00:00Added an answer on May 15, 2026 at 1:22 pm
    var action = '<%=ProdView.ToString() %>'
    

    Don’t forget the quotes.

    Edit to respond on coffee addicts comment

    You have to remember that the code is executed twice, first at server side to generate the text string:

    var action = '<%=ProdView.ToString() %>'
    

    is executed by ASP.net and turned into a complete string before returning it to the web browser

    var action = 'lalalalala'
    

    And the actual java script is executed in the web browser.

    So ASP.net have nothing to do with the actual javascript execution. It’s job is only to generate HTML/javascript/css that will be sent back to the webbrowser.

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

Sidebar

Related Questions

in aspx code behind, define a var like: Public rate as decimal; then in
In my aspx file, I have some code that looks like this: <script type=text/javascript>
aspx script: <script type=text/javascript> $(document).ready(function() { $(.div_soru).hide(); $(.div_soru).first().show(); $(.onceki).click(function() { if ($(this).closest(.div_soru).prev(.div_soru).html() != null)
Inside my .aspx I have some JSON code that looks like this: function someFunctionName()
My aspx page:- <script src=js/jquery-1.4.2.js type=text/javascript></script> <script src=js/jquery-ui-1.8.2.custom.js type=text/javascript></script> <script type=text/javascript> $(document).ready(function () {
my aspx (html) code is like below : this is first button (something that
//aspx <script type=text/javascript> function linkRenderer(value, meta, record) { var customerUrl = '<%=GetPageUrlWithQuery(Pages.CustomerDetails) %>'; return
I have a this aspx-code: (sample) <asp:DropDownList runat=server ID=ddList1></asp:DropDownList> With this codebehind: List<System.Web.UI.WebControls.ListItem> colors
Default.aspx <script type=text/javascript> $(function() { $(#add_questions).click(function() { var question = $(#wmd-output).val(); var option1 =
I have two aspx pages: DashboardPreview.aspx: This is the homepage. It shows top 5

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.