[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

JOSE DIAZ

6/7/2002 6:33:00 PM

Hello!, This is my TIMEFORMVB:

-------BEGIN SOURCE CODE--------------------------

Imports System.ComponentModel
Imports System.Web.UI
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections
Imports System.Web.UI.MobileControls
Imports System.Web.UI.MobileControls.Adapters

' ==================================================================='
' TimerForm Control Class
'
' The TimerForm control inherits from Form, and adds the ability
' to make the browser navigate to a URL or post back to the server
' after a specified time.
'
' To set the specified delay, set the Delay property.
'
' To make the browser navigate to a URL, set the AutoNavigateUrl
' property.
'
' To make the browser post back, leave AutoNavigateUrl blank. To
' handle the resulting event, set an event handler for the Timer
' event, or override OnTimer in an inheriting class.
'
' ===================================================================

Public Class TimerForm : Inherits System.Web.UI.MobileControls.Form

' =============================================================== '
' Delay property
'
' Defines, in seconds, how long to delay before executing action.
' Defaults to ten seconds.
'
' ===============================================================
Public Property Delay() As Integer

Get
Dim o As Object = ViewState("Delay")
If o Is Nothing Then
Return 10
Else
Return CType(o, Integer)
End If
End Get

Set(ByVal Value As Integer)
ViewState("Delay") = Value
End Set

End Property

' =============================================================== '
' AutoNavigateUrl property
'
' If defined, renders markup to make the browser automatically
' navigate to the given URL after the specified time.
'
' ===============================================================
Public Property AutoNavigateUrl() As String

Get
Dim o As Object = ViewState("AutoNavigateUrl")
If o Is Nothing Then
Return String.Empty
Else
Return CType(o, String)
End If
End Get

Set(ByVal Value As String)
ViewState("AutoNavigateUrl") = Value
End Set

End Property

' =============================================================== '
' Timer event
'
' This event is raised when the timer elapses, and the browser
' posts back to the server. If AutoNavigateUrl is defined, no
' postback happens.
'
' ===============================================================
Public Event Timer(ByVal sender As Object, ByVal e As EventArgs)

' =============================================================== '
' OnTimer method
'
' This protected method allows inheriting classes to internally
' handle a post back following the specified delay. The default
' implementation raises the Timer event.
'
' ===============================================================
Protected Overridable Sub OnTimer(ByVal e As EventArgs)

RaiseEvent Timer(Me, e)

End Sub

' =============================================================== '
' RaiseTimer method
'
' Called by the adapters to raise the timer event.
'
' ===============================================================
Public Sub RaiseTimer()

OnTimer(New EventArgs())

End Sub

End Class

' ==================================================================='
' WmlTimerFormAdapter Class
'
' The WmlTimerFormAdapter class renders a TimerForm control on
' WML devices. The timer functionality is rendered using an
' <onevent type="timer"> construct. All other behavior
' is inherited from WmlFormAdapter.
'
' ===================================================================
Public Class WmlTimerFormAdapterVB : Inherits WmlFormAdapter

Private Const TimerEventArgument As String = "$timer"

Protected Shadows ReadOnly Property Control() As TimerForm

Get
Return CType(MyBase.Control, TimerForm)
End Get

End Property

' =============================================================== '
' RenderExtraCardElements method
'
' By overriding this method, the adapter can render additional
' content immediately after the <card> tag in the WML output.
'
' ===============================================================
Protected Overrides Sub RenderExtraCardElements(ByVal writer As
WmlMobileTextWriter)

Dim autoNavigateUrl As String = Control.AutoNavigateUrl

' A URL to another form on the same page will also cause a
postback.

Dim renderAsPostBack As Boolean = False
If autoNavigateUrl.Length = 0 Then
renderAsPostBack = True
ElseIf Not (DeterminePostBack(autoNavigateUrl) Is Nothing) Then
renderAsPostBack = True
End If

writer.WriteBeginTag("onevent")
writer.WriteAttribute("type", "ontimer")
writer.Write(">")

If (renderAsPostBack) Then

writer.RenderGoAction(Control.UniqueID, TimerEventArgument,
WmlPostFieldType.Normal, False)

Else

' Resolve the URL relative to the page.
autoNavigateUrl = Control.ResolveUrl(autoNavigateUrl)

writer.WriteBeginTag("go")
writer.Write(" href=")
writer.Write(Chr(34))
writer.WriteEncodedUrl(autoNavigateUrl)
writer.Write(Chr(34))
writer.Write(">")

End If

writer.WriteEndTag("onevent")
writer.WriteLine()

writer.WriteBeginTag("timer")
' WML timer lengths are in 10th of seconds.
writer.WriteAttribute("value", (Control.Delay * 10).ToString())
writer.WriteLine("/>")

End Sub

' =============================================================== '
' HandlePostBackEvent method
'
' By overriding this method, the adapter can handle the postback
' generated from the timer.
'
' ===============================================================
Public Overrides Function HandlePostBackEvent(ByVal eventArgument As
String) As Boolean

If (eventArgument = TimerEventArgument) Then

Dim autoNavigateUrl As String = Control.AutoNavigateUrl
If autoNavigateUrl.Length > 0 Then

If (autoNavigateUrl.Length > 1) And
(autoNavigateUrl.Chars(0) = "#") Then
Page.ActiveForm Control.ResolveFormReference(autoNavigateUrl.Substring(1))
End If

Else

Control.RaiseTimer()

End If

HandlePostBackEvent = True
Else

' Let the base adapter class handle any events.

HandlePostBackEvent MyBase.HandlePostBackEvent(eventArgument)

End If

End Function

End Class

' ==================================================================='
' HtmlTimerFormHelper Class
'
' The HtmlTimerFormHelper class is a helper class used by both
' HtmlTimerFormAdapter and ChtmlTimerFormAdapter. Although both
' these classes require identical functionality, they have different
' base classes, making a helper class useful.
'
' On HTML devices, the timer functionality is rendered using a
' <meta http-equiv="refresh"> construct. All other behavior
' is inherited from the base form adapter.
'
' ===================================================================
Class HtmlTimerFormHelperVB

Private Const TimerEventArgument As String = "$timer"

' =============================================================== '
' RenderTimerMetaTag method
'
' Renders the metatag for the timer behavior.
'
' ===============================================================
Public Shared Sub RenderTimerMetaTag(ByVal form As TimerForm, ByVal
writer As HtmlMobileTextWriter)

Dim autoNavigateUrl As String = form.AutoNavigateUrl

' A URL to another form on the same page will also cause a
postback.

Dim renderAsPostBack As Boolean = False
If autoNavigateUrl.Length = 0 Then
renderAsPostBack = True
ElseIf autoNavigateUrl.Chars(0) = "#" Then
renderAsPostBack = True
End If

writer.WriteBeginTag("meta")
writer.WriteAttribute("http-equiv", "refresh")
writer.Write(" content=")
writer.Write(Chr(34))
writer.Write(form.Delay.ToString())
writer.Write(";url=")
If renderAsPostBack Then

Dim pageAdapter As HtmlPageAdapter CType(form.MobilePage.Adapter, HtmlPageAdapter)
pageAdapter.RenderUrlPostBackEvent(writer, form.UniqueID,
TimerEventArgument)

Else

writer.WriteEncodedUrl(autoNavigateUrl)

End If
writer.Write(Chr(34))
writer.WriteLine(">")

End Sub

' =============================================================== '
' HandlePostBackEvent method
'
' Handles a timer postback event.
'
' ===============================================================
Public Shared Function HandlePostBackEvent(ByVal form As TimerForm,
ByVal eventArgument As String) As Boolean

If (eventArgument = TimerEventArgument) Then

Dim autoNavigateUrl As String = form.AutoNavigateUrl

If (autoNavigateUrl.Length > 0) Then

If (autoNavigateUrl.Length > 1) And
(autoNavigateUrl.Chars(0) = "#") Then

form.MobilePage.ActiveForm form.ResolveFormReference(autoNavigateUrl.Substring(1))

End If

Else

form.RaiseTimer()

End If

HandlePostBackEvent = True

Else

HandlePostBackEvent = False

End If

End Function

End Class

' ==================================================================='
' HtmlTimerFormAdapter Class
'
' The HtmlTimerFormAdapter class renders a TimerForm control on
' HTML devices. The timer functionality is rendered using a
' <meta http-equiv="refresh"> construct. All other behavior
' is inherited from HtmlFormAdapter.
'
' ===================================================================
Public Class HtmlTimerFormAdapterVB : Inherits HtmlFormAdapter

Protected Shadows ReadOnly Property Control() As TimerForm

Get
Return CType(MyBase.Control, TimerForm)
End Get

End Property

' =============================================================== '
' RenderExtraHeadElements method
'
' By overriding this method, the adapter can render additional
' content inside the <head> tag of the rendered page. The adapter
' must call the base class implementation.
'
' ===============================================================
Protected Overrides Function RenderExtraHeadElements(ByVal writer As
HtmlMobileTextWriter) As Boolean

MyBase.RenderExtraHeadElements(writer)

' The method is called twice - once with the writer set to null,
' to determine if there is anything to be written; and once with
' a valid writer.

If Not (writer Is Nothing) Then

HtmlTimerFormHelperVB.RenderTimerMetaTag(Control, writer)

End If

RenderExtraHeadElements = True

End Function

' =============================================================== '
' HandlePostBackEvent method
'
' By overriding this method, the adapter can handle the postback
' generated from the timer.
'
' ===============================================================
Public Overrides Function HandlePostBackEvent(ByVal eventArgument As
String) As Boolean

If (HtmlTimerFormHelperVB.HandlePostBackEvent(Control,
eventArgument) = True) Then

HandlePostBackEvent = True

Else

' Let the base adapter class handle any events.

HandlePostBackEvent MyBase.HandlePostBackEvent(eventArgument)

End If

End Function

End Class

' ==================================================================='
' ChtmlTimerFormAdapter Class
'
' The ChtmlTimerFormAdapter class renders a TimerForm control on
' scriptless HTML devices. The timer functionality is rendered using
' a <meta http-equiv="refresh"> construct. All other behavior
' is inherited from ChtmlFormAdapter.
'
' ===================================================================
Public Class ChtmlTimerFormAdapterVB : Inherits ChtmlFormAdapter
End Class


----------------END SOURCE CODE ---------------



Now, this is my aspx:

<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="default2.aspx.vb" Inherits="wap.default2" %>
<%@ Register TagPrefix="cc1" Namespace="TimerFormVB"
Assembly="TimerFormVB" %>
<%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls"
Assembly="System.Web.Mobile, Version=1.0.3300.0, Culture=neutral,
PublicKeyToken3f5f7f11d50a3a" %>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/Mobile/Page...
<body Xmlns:mobile="http://schemas.microsoft.com/Mobile/WebForm...
<P>
<cc1:TimerForm id="frmPrueba" runat="server"
AutoNavigateUrl="mpindex.aspx" Delay="5">
<mobile:Label id="lblTitulo" runat="server" Font-Bold="True"
Alignment="Center">CLUB DE PRUEBA</mobile:Label>
</cc1:TimerForm>
</P>
</body>


Is very simple, only there is a label.


This is my code in the web.config :

<mobileControls
cookielessDataDictionaryType="System.Web.Mobile.CookielessData" >
<device name="HtmlDeviceAdapters2" inheritsFrom="HtmlDeviceAdapters">
<control name="TimerFormVB.TimerForm, TimerFormVB"
adapter="TimerFormVB.HtmlTimerFormAdapterVB,TimerFormVB" />
</device>
<device name="ChtmlDeviceAdapters2"
inheritsFrom="ChtmlDeviceAdapters">
<control name="TimerFormVB.TimerForm, TimerFormVB"
adapter="TimerFormVB.ChtmlTimerFormAdapterVB,TimerFormVB" />
</device>
<device name="UpWmlDeviceAdapters2"
inheritsFrom="UpWmlDeviceAdapters">
<control name="TimerFormVB.TimerForm, TimerFormVB"
adapter="TimerFormVB.WmlTimerFormAdapterVB, TimerFormVB" />
</device>
<device name="WmlDeviceAdapters2"
inheritsFrom="WmlDeviceAdapters">
<control name="TimerFormVB.TimerForm, TimerFormVB"
adapter="TimerFormVB.WmlTimerFormAdapterVB, TimerFormVB" />
</device>
</mobileControls>


I hope find the solution in .net because i need this:

1th card: image + title

after 5 seconds

2th card: options

bye and thanks.








*** Sent via Developersdex http://www.develop... ***
Don't just participate in USENET...get rewarded for it!
2 Answers

(Andres Sanabria)

6/13/2002 2:02:00 AM

0

I will do some research and get back to you

Andres

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. © 2002 Microsoft Corporation. All rights
reserved.

(Jose Diaz)

12/26/2002 11:07:00 AM

0

When you use TIMERFORMVB from QUICKSTART Samples in emulator UP.SDK. 4.1,
you see this error:


----------------- DATA SIZE ------------------------
Uncompiled data from HTTP is 343 bytes.
...found Content-Type: text/vnd.wap.wml.

======================= WML Errors =====================
WML translation failed.
(6) : error: Close tag 'onevent' does not match start tag 'go'
(7) : error: Invalid element 'timer' in content of 'onevent'. Expected closing t
ag
(8) : error: Invalid element 'p' in content of 'onevent'. Expected closing tag
(8) : error: Close tag 'card' does not match start tag 'onevent'
(9) : error: Close tag 'wml' does not match start tag 'card'
(9) : error: Expected the end of root element instead of end of file




************************ Current WML ******************************************
<?xml version='1.0'?>
<!DOCTYPE wml PUBLIC '-//WAPFORUM//DTD WML 1.1//EN' 'http://www.wapfor...
/wml_1.1.xml'><wml><head>
<meta http-equiv="Cache-Control" content="max-age=0" />
</head>
<card>
<onevent type="ontimer"><go href="mpindex.aspx"></onevent>
<timer value="50"/>
<p align="center"><b>CLUB DE PRUEBA</b></p></card>
</wml>
********************************************************************************

Translation failed for content-type: text/vnd.wap.wml



Any idea?? in browser is running ok.