2

I'm having a server side global variable in my MVC4 application.

And now i need to use that variable in my View using j Query.

Can any one tell me how can i use that variable in my View using j Query.

Variable

namespace Saif.Models
{
    public class ClsGlobal
    {
        static string _AbsoluterUrl;
        public static string AbsoluterUrl
        {
            get { return _AbsoluterUrl; }
            set { _AbsoluterUrl = value; }
        }
    }
}

In J query $(document).ready

var url = @Saif.Models.ClsGlobal.AbsoluterUrl;

2 Answers 2

2

Try adding '' to the url in your javascript:

var url = '@Saif.Models.ClsGlobal.AbsoluterUrl';

The url will now contain the value of AbsoluteUrl.

Sign up to request clarification or add additional context in comments.

Comments

0

save server side variable value to hidden fields and then use hidden field value in jquery with the help of hidden fields id.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.