0

I have following method

    public string TyneMice()
    {
        return System.IO.File.ReadAllText(@"C:\Users\...\myhtml.html");
    }

I want to call above string method (TyneMIce) using jQuery . whats the syntax need to use ?

kez
  • 2,273
  • 9
  • 64
  • 123
  • You mean `ajax` call?? – Guruprasad J Rao Oct 28 '15 at 03:56
  • nope without ajax , I just want to call this function – kez Oct 28 '15 at 03:57
  • 1
    That function isn't javascript/jquery. If it's a server-side function you have to do a httprequest of some kind. AJAX is a way to do such a request with javascript. – James Oct 28 '15 at 04:06
  • @James yes this function is in c# , I want to call this when View Page loading. so all you saying is I cannot use jquery to call this ? – kez Oct 28 '15 at 04:17
  • 1
    @kez no you can't use client-side languages with server-side languages. the only way this can be achieved is using Ajax to request data from the server. See this detailed answer: http://programmers.stackexchange.com/a/171210 – Joseph118 Oct 28 '15 at 04:18
  • @Joseph118 I tried like this as you guys said , but seems like method not invoking 1. https://bitbucket.org/snippets/Common_Admin/yq4GA/ajax-call 2. https://bitbucket.org/snippets/Common_Admin/KK7x7/ajax-to-call-string-method – kez Oct 28 '15 at 05:17
  • @kez you are almost there. Now take a look at this answer to help you call your method http://stackoverflow.com/a/4508430 – Joseph118 Oct 28 '15 at 07:43

0 Answers0