ASP.NET Topic Making

Discussion in 'Web Programming' started by hoffmann, Apr 10, 2018.

  1. hoffmann

    hoffmann New Member

    After a long haul, hello again, I'm still working on it today - I'll tell you how to make the "popular topics" section of a simple website I am developing. I will describe it on the ASP.NET Web Form project. Do not ask me why you are not using the MVC architecture.

    How does this logic work? You can also see "Popular topics" or another phrase "Most read". The article is based on the number of readings. So the most read article is the most popular topic. I'll show you this on the site that I've been cracked up to. So the database is ready.

    Now I assign a section of the article tablomain.

    As you can see, there are some records in my articles tablom. Here you should have taken your attention to the article reading column. When I click on a article, the number of "article not found" increases by one. Anyway, I guess I made a lot of words. Let's go to the design and data extraction section. I am doing my design using the bootstrap framework. You already know what the card, card-body, row, col-md parts of code you see in the code are. They are the names of our CSS classes. In ASP.NET Web Form projects, data retrieval from the database is done with controls such as DataList, Repeater. Those who need and need this topic already know how to use them. I threw a repeater between tags <ul>. So I shoot with my repeater. Why did I throw it into the ul? Because my data will repeat in the list.

    I just opened the <ItemTemplate> below, what is this? which part I will pick when I draw the data, what HTML element it will be in. Of course I will not talk about them in detail. I put the element in <li> with the expression in "articleBasic". So each title will repeat as a list. Do not hang on to that "<a>" element, I added it as I will also direct the article title to the relevant article content page while taking the title of the article.

    Yes, I have designed which pattern to take and which pattern to take. Now it's time for background codes, ie C # code. Now I will write the fetch operation to the SQL query.

    Our C # code:

     SqlCommand cmdPop = new SqlCommand ("select top (5) * from article order by articleOptimize desc", baglan.baglan ());
                SqlDataReader drpop = cmdpop.ExecuteReader ();
                Rpop.DataSource = drpop;
                rpop.databind ();
    I will not talk about the concepts of DataReader, DataSource, and DataBind. People who knew how to draw data to the page already understood. The main purpose of this is to explain the phenomenon of popular articles.

    The query is very simple. The whole event of this koskoca article is actually in this single line.
    So far everything was theoretically speaking.

    select * from article order by articleOpen desc
    Look, I deleted the "top (5)" part. The code in this article charts the values in the article non-response column according to the ascending-descending order. I mean, this is "DESC". (10-9-8). The "top (5)" we have added to the query indicates that only 5 data should be taken. PHP writers can also use a "limit 5" query. So, why 5? If you want to do 10 you know. But if you have 100 articles, of course you have to have only a certain number of data if you are doing the most popular.

  2. clmaurer

    clmaurer New Member

    A topic that people who want to make blogs or blog-like sites should definitely look at.

Share This Page