Changing out database records automatically

Using a detail view control to cycle through news.

Page 1 of 1

2 Replies - 1916 Views - Last Post: 27 January 2009 - 11:25 AM Rate Topic: -----

#1 MacAnimeGirl   User is offline

  • D.I.C Regular

Reputation: 9
  • View blog
  • Posts: 282
  • Joined: 30-September 08

Changing out database records automatically

Posted 27 January 2009 - 10:06 AM

The components I'm using are as follows in order as it is in the page:
ScriptManager - AJAX
Timer - AJAX
UpdatePanel - AJAX
Detail View - ASP.NET
Access DataSource - ASP.NET

Here's the code for the control I'm creating...

<%@ Control Language="VB" AutoEventWireup="false" CodeFile="wucCompanyNews.ascx.vb" Inherits="wucCompanyNews" %>
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI" TagPrefix="asp" %>
<style type="text/css">
@import "css/companyNews.css";
<div id="divCompanyNews" runat="server">
<asp:ScriptManager ID="smNews" runat="server">
<asp:Timer ID="timerNews" runat="server" Interval="25000">
    <asp:UpdatePanel ID="upNews" runat="server" UpdateMode="Conditional">
                <legend id="header">Company News Overview</legend>
                     AllowPaging="True" >
                        <asp:BoundField DataField="ID" SortExpression="ID" Visible="False"/>
                        <asp:BoundField DataField="Title" SortExpression="Title">
                            <ItemStyle Font-Bold="True" />
                        <asp:BoundField DataField="News" SortExpression="News"  />
            <asp:AccessDataSource ID="adsCompanyNews" runat="server" DataFile="~/databases/dbSite.mdb"
                SelectCommand="SELECT * FROM `CompanyNews`"></asp:AccessDataSource>
                     FirstPageText="|<< " 
                     LastPageText=" >>|" 
                     NextPageText=" > " 
                     PreviousPageText=" < "/>

And here's the code behind the page

Partial Class wucCompanyNews
    Inherits System.Web.UI.UserControl
    Dim browser As String

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        browser = Request.Browser.Type.ToString()
        If browser.StartsWith("IE") = False Then
            divCompanyNews.Attributes.CssStyle("margin-top") = "-115px"
        End If
    End Sub

    Protected Sub timerNews_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles timerNews.Tick

        Dim currentPage As Integer
        Dim maxPages As Integer

        currentPage = dvCompanyNews.PageIndex
        maxPages = dvCompanyNews.PageCount

        If currentPage = maxPages Then
            currentPage = 1
            currentPage = currentPage + 1
        End If

    End Sub
End Class

and then here's the CSS (which for the scrolling part... doesn't seem to be working, nor is the max height.)
	font-size: 0.75em;
	border: none;
	max-height: 110px;
	margin: 0;
	padding: 0;
	text-align: center;
	overflow: scroll;

.dvCompNews a
	text-decoration: none;

	font-weight: bold;

Alright, this page... has a news reel, I'll call it that. The news cycles automatically. That's what I want to do.

So when I went to the Source View for the code..... I couldn't decipher it.... I got overwhelmed.

I thought doing it behind the page might work... but it doesn't it. I thought the code was correct but the news isn't changing...

I left the page count dynamic because there's no telling how much or little news we may have at once.

So... Can anyone help me?

Is This A Good Question/Topic? 0
  • +

Replies To: Changing out database records automatically

#2 Martyr2   User is offline

  • Programming Theoretician
  • member icon

Reputation: 5207
  • View blog
  • Posts: 13,955
  • Joined: 18-April 07

Re: Changing out database records automatically

Posted 27 January 2009 - 11:13 AM

Your rotation on that page has nothing to do with ASP.NET. It is a script run through the prototype-scriptaculous javascript framework. If you look at the source of the page you will see javascript that creates the AlaUne object (about three fourths the way down the source code written in JSON) and in that object you will see it creates a "PeriodicalExecuter" object which is part of the framework. These two objects combined are creating the slide show effect of the news reel.

This is a client-side effect they are doing here, not a server-side effect so the code behind of ASP is not going to be effective here unless it generates javascript for you in the page to be run on the client. I suggest that you look into how to use prototype-scriptaculous if you want to better understand what is going on with the code here.

And as for your questions not being answered.... some tips to help.

1) Know that ASP.NET is one of our slower forums.
2) When you ask a question, try to narrow the scope instead of throwing up everything you have. It just overwhelms the answerer to what is relevant to the problem and not. If it is too much work to find out what you are even asking, they don't bother with it.
3) Try to describe your problem in more detail and not "help me do this". We are about getting you out of code problems you are having with your code, not teaching you how to do other things. That is what our tutorials/snippets sections are for.

Lastly, please do not contact people via PM to have them come answer your question. They will answer when they see it and can help. Consider this a favor that I have provided you an answer to this. We do appreciate our members asking questions and encourage it, but if we answered all the private messages asking for help you would be at the end of a very long line and you would never get a timely response.

Thanks! :)
Was This Post Helpful? 0
  • +
  • -

#3 MacAnimeGirl   User is offline

  • D.I.C Regular

Reputation: 9
  • View blog
  • Posts: 282
  • Joined: 30-September 08

Re: Changing out database records automatically

Posted 27 January 2009 - 11:25 AM

Thank you.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1