Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript file access to resources asp.net mvc

    public static JavaScriptResult JavascriptResources(ResourceManager manager, string resourceObjectName, CultureInfo culture)
    {
        ResourceSet resourceSet = manager.GetResourceSet(culture, true, true);

        StringBuilder sb = new StringBuilder();

        sb.AppendFormat("var {0}=new Object();", resourceObjectName);

        var enumerator = resourceSet.GetEnumerator();
        while (enumerator.MoveNext())
        {
            sb.AppendFormat("{0}.{1}='{2}';", resourceObjectName, enumerator.Key,
                System.Web.HttpUtility.JavaScriptStringEncode(enumerator.Value.ToString()));
        }

        return new JavaScriptResult()
        {
            Script = sb.ToString()
        };
    }
Comment

javascript file access to resources asp.net mvc

public class ResourcesController : Controller
{
    [OutputCache(Duration = 36000, VaryByParam = "lang")]
    // Duration can be many hours as embedded resources cannot change without recompiling.
    // For the clients, I think 10 hours is good.
    public JavaScriptResult Index(string lang)
    {
        var culture = new CultureInfo(lang);
        return Helpers.JavascriptResources(Resources.Client.ResourceManager,
            "Client", culture);
    }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: postfix increment 
Javascript :: configuration file must specify a supported nodejs10 version that is compatible with the runtime specified in the deployment. 
Javascript :: -d {followingjson} curl 
Javascript :: javascript random six digit number with animation 
Javascript :: mat slider in a reactve form 
Javascript :: Uncaught ReferenceError: jQuery is not defined at (index): "405" 
Javascript :: javascript copy array map 
Javascript :: strip js for subscription 
Javascript :: how to update value in nested json using id in javascript 
Javascript :: if typeof equals array javascript 
Javascript :: site completo com ajax jquery 
Javascript :: get each primary colour and add into an array javascript 
Javascript :: how to add a object in world in matter.js 
Javascript :: undo npm run eject react 
Javascript :: write confirm dialog box if yes then run function using php 
Javascript :: cluster mapping d3js example 
Javascript :: vuetifyjs 2.0 2 column side bar 
Javascript :: insert html block and dynamic content 
Javascript :: how to sort a 2d array in javascript 
Javascript :: how to bind the dropdown data using ajax in .net mvc 
Javascript :: Nodejs - non-flowing data stream 
Javascript :: dateFormat 
Javascript :: press enter reaction js 
Javascript :: safe check in js 
Javascript :: MAT_DIALOG_SCROLL_STRATEGY 
Javascript :: tinymce-angular load slow 
Javascript :: click eventlistener is not works on radio button using javascript 
Javascript :: javascript function to print hello world 
Javascript :: tableexport dates 
Javascript :: AngularJS module can be created using ............ A. module.create(); B.angular.create(); C.angular.module(); D.var myModule = new module(); 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =