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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:41:01+00:00 2026-06-01T23:41:01+00:00

I have a value in my span, which i want to compare with C#

  • 0

I have a value in my span, which i want to compare with C# variable, is it possible ?? If yes, then How ??

I can get the Html tag values in Jquery variable, but still not succeeding to get it to compare it with a C# variable value in Razor View.

HTML Tag: <span style="visibility: hidden" id="category">"Some Value"</span>

C# Razor Syntax :

@foreach (var item in Model.InventoryViewModel.Items.Where(i => i.Category == "HTML Value"))
            {
// Some Code
}

I am trying to match the value in span with C# variable, any help suggestions please :\ !!

  • 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-06-01T23:41:03+00:00Added an answer on June 1, 2026 at 11:41 pm

    no idea what you are doing but you could use a variable or something, or even better a property on your view model. Anyway Razor code runs on the server, HTML is on the client so talking about comparing HTML values in Razor is like the chicken and egg problem.

    So you could generate your pan tag with a value of your view model:

    <span style="visibility: hidden" id="category">
        @Model.SomeProperty
    </span>
    

    and then you compare:

    @foreach (var item in Model.InventoryViewModel.Items.Where(i => i.Category == Model.SomeProperty))
    {            
        // Some Code
    }
    

    but even better would be to perform this on the controller action and directly filter the collection so that all you have to do in the view is:

    @foreach (var item in Model.InventoryViewModel.FilteredItems)
    {
        // Some Code
    }
    

    or even shorter using templates:

    @Html.EditorFor(x => x.InventoryViewModel.FilteredItems)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have value in php variable like that $var='2.500000550'; echo $var what i want
I want to get a regex which will match a tag in a java
Assuming I have the following html div which I want to replicate its children,
I have this structure on form, <input type=test value= id=username /> <span class=input-value>John Smith</span>
I have the following echo <span>.apply_filters( $value\n, $value).</span>; that outputs <span>Value</span> <span>value 2</span> <span>value
Imagine that i have the following code: <a:repeat value=#{bean.getList()} var=x > <li class=la> <span>
I have string value and Type of some variable (For example int and 32
I have the value of the epoch time like say 123456789, now I want
I have a mytable which contains mytd inturn contains the Myspan i want to
I have input box txtRefreshInterval which allow only integer. <td><span class=sfFormlabel>Refresh Interval</span></td> <td><input type=text

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.