Snake multi-screen picture switching (can add picture links and edit titles) _ Practical Tips

Source: Internet
Author: User
Friend request, do a multiple screen picture switching effect, as a website advertising, just started to hear this request, I thought must be very simple copy on the line. But friends have further requirements, is to manage after the site management, add pictures, links and titles. You can also edit this information. The front desk does not have to modify the foreground code every time it is updated.

Then the friend has this request, insus.net just do it. First look at the effect (this is the year of the snake, just Windows 8 themes also have some pictures of snakes, so take it for example.) )


Create a table in the database to store related information, such as picture names, links, and headings:
Copy Code code as follows:

[dbo]. [Switchfocusnews]
SET ANSI_NULLS on
Go
SET QUOTED_IDENTIFIER ON
Go
-- =============================================
--Author:Insus.NET
--Create date:2013-01-12
--Description: Create Picture switching information table
-- =============================================
CREATE TABLE [dbo]. [Switchfocusnews]
(
[NBR] TINYINT IDENTITY (1,1) PRIMARY KEY not NULL,
[ImageName] NVARCHAR (128) not NULL,
[URL] NVARCHAR not NULL,
[Title] NVARCHAR not NULL
)
Go

Create a stored procedure to get all the records:
Copy Code code as follows:

[dbo]. [Usp_switchfocusnews_getall]
SET ANSI_NULLS on
Go
SET QUOTED_IDENTIFIER ON
Go
-- =============================================
--Author:Insus.NET
--Create date:2013-01-12
--Description: Get All records
-- =============================================
CREATE PROCEDURE [dbo]. [Usp_switchfocusnews_getall]
As
SELECT [Nbr],[imagename],[url],[title] from [dbo]. [Switchfocusnews]
Go

The website backstage uploads the picture, as well as the editing function, Insus.net here omits.

Next, you create a category that only gets information about the database table, and the other additions, edits, and deletions are slightly different.
Copy Code code as follows:

Switchfocusnews
Imports System.Data
Imports Microsoft.VisualBasic
Namespace insus.net
Public Class Switchfocusnews
Dim Objbusinessbase as New businessbase ()
Public Function GetAll () as DataTable
Return Objbusinessbase.getdatatodataset ("Usp_switchfocusnews_getall"). Tables (0)
End Function
End Class
End Namespace

In order to maintain convenience later, as well as the minimal functionality of the development concept, insus.net it into a user control ascx, the following HTML code, the emphasis is placed between <script> put a asp:literal control. Also, CSS and JS is also in this reference.
Copy Code code as follows:

<%@ control language= "VB" autoeventwireup= "false" codefile= "FlashAnimation.ascx.vb" inherits= "Ascxcontrols_" Flashanimation "%>
<link href= ' <%= resolveurl ("~/flashanimation/css/lrtk.css")%> ' rel= ' stylesheet '/>
<script src= ' <%= resolveurl ("~/flashanimation/js/pptbox.js")%> ' ></script>
<div id= "Insus" >
<script>
<asp:literal id= "Literalswitchimage" runat= "Server" ></asp:Literal>
</script>
</div>

User Control CS Code
Copy Code code as follows:

Imports System.Data
Imports insus.net
Partial Class ascxcontrols_flashanimation
Inherits System.Web.UI.UserControl
' Instantiate category
Dim Objswitchfocusnews as New switchfocusnews ()
Protected Sub Page_Load (sender as Object, e as EventArgs) Handles Me.load
Dim objdatatable as DataTable = Objswitchfocusnews.getall ()
' See if the database has records
If objDataTable.Rows.Count > 0 Then
Dim width as Integer = 500 ' width
Dim height as Integer = 300 ' height
Dim Autoplayer as Integer = 3 ' Auto play time interval
Dim si as New StringBuilder ()
Si. AppendFormat ("var box = new Pptbox ();")
Si. AppendFormat ("Box.width = {0};", width)
Si. AppendFormat ("Box.height = {0};", height)
Si. AppendFormat ("Box.autoplayer = {0};", Autoplayer)
' Circular datasheet, which loops through each record in the following syntax. The path to the picture is the path that is stored when the background is uploaded or edited. Of course, you can also display the image stored in the data.
For all Dr as DataRow in Objdatatable.rows
Si. AppendFormat ("Box.add ({{)" "url": "" {0} "", "href" ":" "{1}" "," "title" ":" "{2}"}}); ", ResolveUrl (" ~/flashanimation/ images/"& Dr (" imagename "). ToString () & ""), Dr ("Url"). ToString (), Dr ("Title"). ToString ())
Next
Si. Append ("Box.show ();")
Me.LiteralSwitchImage.Text = Si. ToString ()
End If
End Sub
End Class

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.