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

  • SEARCH
  • Home
  • 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 8394789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:08:40+00:00 2026-06-09T20:08:40+00:00

I have a C# Property CategoryID , I want to set it’s value in

  • 0

I have a C# Property CategoryID, I want to set it’s value in Javascript.

I am trying to set the value CategoryID like below:

var sPath = window.location.pathname;
var catId = null;

var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
if (sPage == 'xyz.aspx')
{
    <%=CommonUtility.CategoryID=4%>;
}
else if(sPage == 'zxy.aspx')
{
    <%=CommonUtility.CategoryID=5%>;
}

But by this method I always get the value of CategoryID= 5(which is in else block) .

Please suggest me how can get the Property value based on condition.

  • 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-09T20:08:42+00:00Added an answer on June 9, 2026 at 8:08 pm

    You can’t set a C# property from a client-side (js). You may use ajax to do some work, but you simply can’t manipulate server-side code.

    edit:

    if you still wonder how it’s possible you get a value, see Mike’s explanation of that fact. But the truth remains. You can’t. It’s impossible. If you want to know the longer explanation, see how asp.net actually works, it’s lifecycle etc. Simple way of putting it would be like this:

    A user sends a request to the server using his browser. The server receives it, creates a requested page and instantiates needed classes etc. Then it’s gets parsed and sent to the client as html (and other resources of course, like images, css…). The instantiated page class CAN’T be accessed and modified afterwards by the client, because it’s already flushed by the server. Every request creates a new instance. There’s no way of interacting js with c# anyway. Can you imagine what it would be like, if you could use some js to modify C# on a remote server? It doesn’t make sense at all.

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

Sidebar

Related Questions

hi i have property named. public bool ShowLabels{get; set;} and one toolbar menu button
I have a property of type uint on my entity. Something like: public class
I have a user control that exposes a property of type ImageSource. I want
I have a control, with a dependency property IsLightOnVal witch is define like this:
I have a set of custom PropertyDescriptor that I want to add categories too
I have property management application consisting of tables: tenants landlords units properties vendors-contacts Basically
I have a property in my backing bean that returns html code: public String
I have a property in my view model which returns a constant under some
I have a property an NSArray property called toolbarButtons that in one instance (when
I have a property that RaisePropertyChanged(PropName, oldValue, true, true) when I don't have any

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.