Click here to Skip to main content
15,908,015 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hello
I am switching from asp.net to web API, my problem is that I don't know how to create a listview in web API. I want to create it without asp controls and using jquery and ajax. can you please help me ?

I wan to know how to write these codes without asp controls:

C#
<asp:ListView runat="server" ID="lvProducts">
 <itemtemplate>
                    
    ;div class="name"><a href="UProductDetail.aspx?PrID= " + Eval("PrID")">;span><%# Eval("PrName") %></span></a></div>

    <div class="big-btns"> <a href="UProductDetail.aspx?PrID= " + Eval("PrID") ">More Detail;/a> <asp:Button runat="server" ID="btnAddBasket" Text="Add to Basket" OnClick="btnAddBasket_Click" CommandArgument=' Eval("PrID") '/div>


I don't know how to use "commandArgument" in jquery and how to build the ListView and go to product detail by the Product ID selected

What I have tried:

I have tried jqxWidget such as jqxListBox but it didn't help me to simulate the code above
Posted
Updated 16-Nov-16 4:08am
v2

You can't create any visual components in WebAPI, I think you're getting confused with your technologies.
 
Share this answer
 
Comments
Ali Majed HA 16-Nov-16 9:42am    
Hello and Thanks for your comment
so should I continue working with old asp.net ?
How should I switch to new technologies ?
You are right, I am very confused.
F-ES Sitecore 16-Nov-16 10:26am    
I think what you're looking for is MVC. There are similarities between WebAPI and MVC, however MVC supports serving of html so that's probably what you want to use.
WebAPI has not visual elements. It's used to provide an interface that exposes methods for other applications to interact with data exposed by your WebAPI.

If you're making a website, you continue to use ASP.NET. WebAPI is entirely separate and is used for a very different purpose.

Your ASP.NET app CAN use a WebAPI to do its data manipulation, essentially using the very same interface a Windows Forms app, or a WPF app, or a mobile app uses to interact with the very same data.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900