Insertar AdSense para móviles en ASP.NET

prueba.jpgJugueteado con AdSense para móviles cree una página para dispositivos celulares con Visual Studio 2005, por lo que pense en un ejemplo de un restaurante que admite reservas por internet. Inicialmente el código no funcionaba en ASP.NET por lo que tuve que retocarlo y parece funcionar. Sólo me faltaba hacer click para verificar que va bien, pero por aquello de las políticas…. pues me quede con las ganas. Nos obstante te he dejado el código para que te sirva de guía si quieres implementar AdSense, recuerda que cuando agreges una página tiene que ser para dispositivos móviles y con todo el código en la página. La página está probada con un nokia 6280

<%@ Page Language=”VB” Inherits=”System.Web.UI.MobileControls.MobilePage” aspcompat=”true” %>
<%@ Register TagPrefix=”mobile” Namespace=”System.Web.UI.MobileControls” Assembly=”System.Web.Mobile” %>

<script runat=”server”>

Function googleColor(value, random)
Dim colorArray
colorArray = Split(value, “,”)
googleColor = colorArray(random Mod (UBound(colorArray) + 1))
End Function

Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs)
Dim googleTime As Object = DateDiff(“s”, “01/01/1970 00:00:00″, Now())
Dim googleDt As Object = (1000 * googleTime) + Math.Round(1000 * (Timer – Int(Timer)))
Dim googleScheme As Object = “http://”
Dim googleHost As Object

If StrComp(Request.ServerVariables(“HTTPS”), “on”) = 0 Then googleScheme = “https://”
googleHost = Server.UrlEncode(googleScheme & Request.ServerVariables(“HTTP_HOST”))

Dim googleAdUrl As String
Dim googleAdOutput As Object
googleAdUrl = “http://pagead2.googlesyndication.com/pagead/ads?” & _
“ad_type=text” & _
“&channel=6881122239″ & _
“&client=ca-mb-pub-9636130745065109″ & _
“&dt=” & googleDt & _
“&format=mobile_single” & _
“&host=” & googleHost & _
“&ip=” & Server.UrlEncode(Request.ServerVariables(“REMOTE_ADDR”)) & _
“&markup=xhtml” & _
“&oe=utf8″ & _
“&output=xhtml” & _
“&ref=” & Server.UrlEncode(Request.ServerVariables(“HTTP_REFERER”)) & _
“&url=” & googleHost & Server.UrlEncode(Request.ServerVariables(“URL”)) & _
“&useragent=” & Server.UrlEncode(Request.ServerVariables(“HTTP_USER_AGENT”))

googleAdOutput = Server.CreateObject(“MSXML2.ServerXMLHTTP”)
googleAdOutput.Open(“GET”, googleAdUrl, False)
googleAdOutput.Send()
Response.Write(googleAdOutput.responseText)
End Sub
</script>

<html xmlns=”http://www.w3.org/1999/xhtml” >
<body>

<mobile:form id=”form1″ runat=”server”>
<mobile:Label
ID=”laReserva” Runat=”server”>Indique el día de reserva</mobile:Label>

<br />

<mobile:SelectionList
ID=”slDia” Runat=”server” Rows=”1″ SelectType=”Radio”>
<Item Selected=”True” Text=”Hoy” Value=”Hoy” />
<Item Text=”Mañana” Value=”Mañana” />
</mobile:SelectionList>

<mobile:Label ID=”laHora” Runat=”server”>Hora de la reserva</mobile:Label>

<mobile:SelectionList
ID=”slHora” Runat=”server”>
<Item Text=”20:00″ Value=”20:00″ />
<Item Selected=”True” Text=”21:00″ Value=”21:00″ />
<Item Text=”22:00″ Value=”22:00″ />
<Item Text=”23:00″ Value=”23:00″ />
</mobile:SelectionList>

<mobile:Label ID=”laNombre” Runat=”server”>Nombre de la reserva</mobile:Label>
<mobile:TextBox ID=”tbNom” Runat=”server”></mobile:TextBox>

<mobile:Label ID=”laTel” Runat=”server”>Teléfono</mobile:Label>

<mobile:TextBox ID=”tbTel” Runat=”server”></mobile:TextBox>

<mobile:Command ID=”btEnviar” Runat=”server”>Hacer reserva</mobile:Command>
</mobile:form>
</body>
</html>

¿Quieres unirte a la conversación? envía tú comentario y continua la conversación, o sucribete a mi "feed" y obtén mis articulos en tu lector favorito.

Comentarios

Aún no hay comentarios.

Dejar un comentario

(requerido)

(requerido)