Reputation: 2706
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.
namespace Saif.Models
{
public class ClsGlobal
{
static string _AbsoluterUrl;
public static string AbsoluterUrl
{
get { return _AbsoluterUrl; }
set { _AbsoluterUrl = value; }
}
}
}
var url = @Saif.Models.ClsGlobal.AbsoluterUrl;
Upvotes: 2
Views: 1096
Reputation: 3384
Try adding ''
to the url in your javascript:
var url = '@Saif.Models.ClsGlobal.AbsoluterUrl';
The url
will now contain the value of AbsoluteUrl
.
Upvotes: 2
Reputation: 37
save server side variable value to hidden fields and then use hidden field value in jquery with the help of hidden fields id.
Upvotes: 0