Quantcast
Channel: CodeProject Latest postings for ASP.NET
Viewing all articles
Browse latest Browse all 3938

Calling get method using typescript

$
0
0
Hi all,

I have an ASP.Net MVC application using Web API Controller, I want to call get method for Button Click using TypeScript, here is my Web Api Controller and its action method.
 
publicclass HomeController : ApiController
{
    [System.Web.Http.ActionName("GetByString")]public IEnumerable<File834Dto> Get(string subscriberNumber)
        {var someObj = SearchResults.SearchBySubscriberNumber(subscriberNumber);return (someObj != null) ? someObj.FileResults : null;//NorthwindEntities db = new NorthwindEntities();//var data = from item in db.Customers//           select item;//return data.ToList();        }
}

And here is my HTML, I want to bind the results to the divSearchResult listbox, any sort of help would be very helpful, I am little bit new to the front end world, thanks in advance.

@{
ViewBag.Title = "Home Page";
}

<script src="~/Scripts/Search/search.js"></script>

<!DOCTYPE html>

<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Home Page</title>
</head>

<body style="position: absolute; height: 98%;min-height:98%;width:85%;min-width:85%;">
<div style="position: absolute; height: 90%;min-height:90%;width:95%;min-width:95%;">
<div style="position: absolute; height: 90%;min-height:90%;width:95%;min-width:95%;">
 
&lt;div id="divSearchResult" style="height: 90%;min-height:90%;width:95%;min-width:95%;"&gt;&lt;select name="cars" multiple="multiple" style="position: absolute; top:5%;"&gt;&lt;option value="volvo"&gt;Volvo Volvo Volvo Volvo Volvo Volvo Volvo Volvo Volvo Volvo Volvo Volvo Volvo Volvo Volvo Volvo&lt;/option&gt;&lt;option value="saab"&gt;Saab&lt;/option&gt;&lt;option value="fiat"&gt;Fiat&lt;/option&gt;&lt;option value="audi"&gt;Audi&lt;/option&gt;&lt;/select&gt;&lt;label style="position: absolute; left:400px; top :5%;"&gt;Test&lt;/label&gt;&lt;select name="cars" multiple="multiple" style="position: absolute; left:400px; top :10%;"&gt;&lt;option value="volvo"&gt;Volvo Volvo Volvo Volvo Volvo Volvo Volvo Volvo Volvo Volvo Volvo Volvo Volvo Volvo Volvo Volvo&lt;/option&gt;&lt;option value="saab"&gt;Saab&lt;/option&gt;&lt;option value="fiat"&gt;Fiat&lt;/option&gt;&lt;option value="audi"&gt;Audi&lt;/option&gt;&lt;/select&gt;&lt;/div&gt;&lt;div id="divSearch"&gt;&lt;p&gt;&lt;input type="text" name="txtSubscriberIdOrName"&gt;&lt;/p&gt;&lt;p&gt;&lt;button style="width: 150px; border-radius: 5px; background: url('../../Content/Images/search-icon-psd-png.jpg'); background-size: 25%, 25%, 25%;background-repeat: no-repeat;"
                        id="search_report"&gt;
                    Search&lt;/button&gt;&lt;/p&gt;&lt;/div&gt;&lt;div id="message"&gt;&lt;/div&gt;&lt;div&gt;
            Compiler: &lt;input id="compiler" value="TypeScript" onkeyup="document.getElementById('message').innerText = sayHello()" /&gt;&lt;br /&gt;
            Framework: &lt;input id="framework" value="ASP.NET" onkeyup="document.getElementById('message').innerText = sayHello()" /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

</body>
</html>
 
Thanks,

Abdul Aleem

"There is already enough hatred in the world lets spread love, compassion and affection."

Viewing all articles
Browse latest Browse all 3938

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>