I have a view which is very simple. It contains some C# code.
@{
ViewBag.Title = "Community";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<div id="req1">
<form>
<input id="txt1" type="text" name="txt1" />
</form>
</div>
<div id="btn1">Send</div>
<div id="res1"></div>
@{
public string GetPassage(string strSearch)
{
using (var c = new System.Net.WebClient())
{
string url = "http://www.esvapi.org/v2/rest/passageQuery?key=IP&passage=' + strSearch + '&options=include-passage-references=true";
return c.DownloadString(Server.UrlDecode(url));
}
}
}
I don't know what is wrong. The error message is:
Source Error:
Line 117:EndContext("~/Views/Home/Community.cshtml", 236, 9, true);
Update:
If I moved the code to controller.
public ActionResult Community()
{
ViewBag.Message = "";
return View();
}
public string GetPassage(string strSearch)
{
using (var c = new System.Net.WebClient())
{
string url = "http://www.esvapi.org/v2/rest/passageQuery?key=IP&passage=" + strSearch + "&options=include-passage-references=true";
return c.DownloadString(Server.UrlDecode(url));
}
}
And I want to make a ajax call based on the example. How is the code in javascript?
' + strSearch + 'should be" + strSearch + ".