Komponen Rotator Konten ASP (ASP 3.0)


Komponen Rotator Konten ASP

Komponen Rotator Konten ASP membuat objek ContentRotator yang menampilkan string konten berbeda setiap kali pengunjung memasuki atau menyegarkan halaman.

File teks, yang disebut File Jadwal Konten, menyertakan informasi tentang string konten.

String konten dapat berisi tag HTML sehingga Anda dapat menampilkan semua jenis konten yang dapat diwakili oleh HTML: teks, gambar, warna, atau hyperlink.

Sintaksis

<%
Set cr=Server.CreateObject("MSWC.ContentRotator")
%>

Contoh Rotator Konten ASP

Contoh berikut menampilkan konten yang berbeda setiap kali pengunjung melihat halaman Web.

Pertama, buat file teks bernama "textads.txt" dan letakkan di subfolder bernama "teks".

"textads.txt":

%% #3
<h2>This is a great day!!</h2>

%% #3
<img src="smiley.gif">

%% #4
<a href="https://www.w3schools.com">Visit W3Schools.com</a>

Perhatikan #nomor di awal setiap string konten. Angka ini adalah parameter opsional yang menunjukkan bobot relatif dari string konten HTML. Dalam file teks di atas, Rotator Konten akan menampilkan string konten pertama dan kedua tiga per sepuluh waktu, dan string ketiga empat per sepuluh waktu.

Kemudian, buat file ASP, dan masukkan kode berikut:

Contoh

<html>
<body>
<%
set cr=server.createobject("MSWC.ContentRotator")
response.write(cr.ChooseContent("text/textads.txt"))
%>
</body>
</html>



Metode Komponen Rotator Konten ASP

Method Description Example
ChooseContent Gets and displays a content string <%
dim cr
Set cr=Server.CreateObject("MSWC.ContentRotator")
response.write(cr.ChooseContent("text/textads.txt"))
%>

Output:

Smiley

GetAllContent Retrieves and displays all of the content strings in the text file <%
dim cr
Set cr=Server.CreateObject("MSWC.ContentRotator")
response.write(cr.GetAllContent("text/textads.txt"))
%>

Output:

This is a great day!!

Smiley

Visit W3Schools.com