Código HTML:
<script language="JavaScript"> var marqueewidth=970 var marqueeheight=25 var marqueespeed=1 var pauseit=1 var marqueecontent='Hola como estas?' marqueespeed=(document.all)? marqueespeed : Math.max(1, marqueespeed-1) var copyspeed=marqueespeed var pausespeed=(pauseit==0)? copyspeed: 0 var iedom=document.all||document.getElementById var actualheight='' var cross_marquee, ns_marquee function populate(){ if (iedom){ cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee cross_marquee.style.left=marqueewidth+9 cross_marquee.innerHTML=marqueecontent actualheight=cross_marquee.offsetHeight } else if (document.layers){ ns_marquee=document.ns_marquee.document.ns_marquee2 ns_marquee.left=marqueewidth+9 ns_marquee.document.write(marqueecontent) ns_marquee.document.close() actualheight=ns_marquee.document.height } lefttime=setInterval("scrollmarquee()",40) } function scrollmarquee(){ if (iedom){ if (parseInt(cross_marquee.style.left)>(marqueewidth*(-1)+8)) cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed else cross_marquee.style.left=marqueewidth+8 } else if (document.layers){ if (ns_marquee.left>(actualheight*(-1)+8)) ns_marquee.left-=copyspeed else ns_marquee.left=marqueewidth+8 } } if (iedom||document.layers){ with (document){ if (iedom){ write('<div style="position: relative; border-style: solid; border-color: #000000; border-width: 1px; width: '+marqueewidth+'; height: '+marqueeheight+'; overflow: hidden; background: #cccccc;" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">') write('<div id="iemarquee" style="position:absolute; left:0; top:0; width:'+marqueewidth+';">') write('</div></div>') } else if (document.layers){ write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee">') write('<layer name="ns_marquee2" width='+marqueewidth+' height='+marqueeheight+' left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>') write('</ilayer>') } } } </script>
Código HTML:
<body onload="populate()" MS_POSITIONING="GridLayout">
El problema esta cuando lo quiero meter en el Codebehind para pasarle la informacion de mi consulta, por que no me despliega el texto, solo me dibuja la marquecina, el codigo que tengo es el siguiente:
Código:
El codigo anterior es el mismo script pero en una cadena, pero como ya les mencione solo me muestra el marco y no me despliega el texto, lo quiero tener en el Codebehind por que le voy a pasar una cadena que viene de una consulta a la variable marqueecontent, por eso necesito tenerlo ahi, no se a que se deba que no se ejecute la funcion de java y solo se dibuje el marco.Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Not IsPostBack Then Dim Cadena As String = "Hola como estas?" Dim sJScript2 As String = "<scr" & "ipt language=""JavaScript"">" & vbCrLf & _ "var marqueewidth=970" & vbCrLf & _ "var marqueeheight=25" & vbCrLf & _ "var marqueespeed=1" & vbCrLf & _ "" & vbCrLf & _ "var pauseit=1" & vbCrLf & _ "" & vbCrLf & _ "" & vbCrLf & _ "var marqueecontent='AQUI VA LO QUE TIENE QUE MOSTRAR'" & vbCrLf & _ "" & vbCrLf & _ "" & vbCrLf & _ "marqueespeed=(document.all)? marqueespeed : Math.max(1, marqueespeed-1) " & vbCrLf & _ "var copyspeed=marqueespeed" & vbCrLf & _ "var pausespeed=(pauseit==0)? copyspeed: 0" & vbCrLf & _ "var iedom=document.all||document.getElementById" & vbCrLf & _ "var actualheight=''" & vbCrLf & _ "var cross_marquee, ns_marquee" & vbCrLf & _ "" & vbCrLf & _ "function populate(){" & vbCrLf & _ "if (iedom){" & vbCrLf & _ "cross_marquee=document.getElementById? document.getElementById(""iemarquee"") : document.all.iemarquee" & vbCrLf & _ "cross_marquee.style.left=marqueewidth+9" & vbCrLf & _ "cross_marquee.innerHTML=marqueecontent" & vbCrLf & _ "actualheight=cross_marquee.offsetHeight" & vbCrLf & _ "}" & vbCrLf & _ "else if (document.layers){" & vbCrLf & _ "ns_marquee=document.ns_marquee.document.ns_marquee2" & vbCrLf & _ "ns_marquee.left=marqueewidth+9" & vbCrLf & _ "ns_marquee.document.write(marqueecontent)" & vbCrLf & _ "ns_marquee.document.close()" & vbCrLf & _ "actualheight=ns_marquee.document.height" & vbCrLf & _ "}" & vbCrLf & _ "lefttime=setInterval(""scrollmarquee()"",40)" & vbCrLf & _ "}" & vbCrLf & _ "" & vbCrLf & _ "function scrollmarquee(){" & vbCrLf & _ "" & vbCrLf & _ "if (iedom){" & vbCrLf & _ "if (parseInt(cross_marquee.style.left)>(marqueewidth*(-1)+8))" & vbCrLf & _ "cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed" & vbCrLf & _ "else" & vbCrLf & _ "cross_marquee.style.left=marqueewidth+8" & vbCrLf & _ "}" & vbCrLf & _ "else if (document.layers){" & vbCrLf & _ "if (ns_marquee.left>(actualheight*(-1)+8))" & vbCrLf & _ "ns_marquee.left-=copyspeed" & vbCrLf & _ "else" & vbCrLf & _ "ns_marquee.left=marqueewidth+8" & vbCrLf & _ "}" & vbCrLf & _ "}" & vbCrLf & _ "" & vbCrLf & _ "if (iedom||document.layers){" & vbCrLf & _ "with (document){" & vbCrLf & _ "if (iedom){" & vbCrLf & _ "write('<div style=""position: relative; border-style: solid; border-color: #000000; border-width: 1px; width: '+marqueewidth+'; height: '+marqueeheight+'; overflow: hidden; background: #cccccc;"" onMouseover=""copyspeed=pausespeed"" onMouseout=""copyspeed=marqueespeed"">')" & vbCrLf & _ "write('<div id=""iemarquee"" style=""position:absolute; left:0; top:0; width:'+marqueewidth+';"">')" & vbCrLf & _ "write('</div></div>')" & vbCrLf & _ "}" & vbCrLf & _ "else if (document.layers){" & vbCrLf & _ "write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name=""ns_marquee"">')" & vbCrLf & _ "write('<layer name=""ns_marquee2"" width='+marqueewidth+' height='+marqueeheight+' left=0 top=0 onMouseover=""copyspeed=pausespeed"" onMouseout=""copyspeed=marqueespeed""></layer>')" & vbCrLf & _ "write('</ilayer>')" & vbCrLf & _ "}" & vbCrLf & _ "}" & vbCrLf & _ "}" & vbCrLf & _ "</" & "script>" 'If (Not IsClientScriptBlockRegistered("populate()")) Then ' RegisterClientScriptBlock("populate()", _ ' sJScript2) 'End If 'Response.Write(sJScript2) RegisterStartupScript("script", sJScript2) End If 'Introducir aquí el código de usuario para inicializar la página End Sub
Las dudas que tengo son:
1 Alguien sabe como le hago para que el Script corra bien desde mi codebehind?
2 O alguien sabe como le podria pasar una cadena al script estando este en el HTML?
3 O alguna recomendacion ?
Por cierto ya vi el Addrotator y no quiero usar XML.
Cualquier comentario o ayuda de antemano gracias.