domingo, 10 de noviembre de 2013

Cómo incluir JavaScript Entre Vb.NET

Integrar JavaScript en su Basic. NET Visual (VB.NET) le permite utilizar ambos lenguajes de programación en una sola función. Esto le ayuda a crear contenido web dinámico para su sitio web con una página ASP.NET. Incluyendo código de JavaScript en una función VB.NET se realiza creando un objeto "ClientScriptManager" que maneja scripts y su método "RegisterStartupScript", que registra una secuencia de comandos específicos de la página.

 

INCLUIR JAVASCRIPT

 

Abra el archivo ASP en un editor como el Bloc de notas de Windows.

 

Establezca el idioma de la página de "VB" y especifique el "DOCTYPE" añadiendo el siguiente código al principio del archivo:

 

% @ Page Language = "VB"%

 

! DOCTYPE HTML PUBLIC "- / / W3C / / DTD XHTML 1.0 Transitional / / EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"

 

Cree una subrutina VB que utiliza código JavaScript a través del uso del método "RegisterStartupScript" agregando el siguiente código después de la línea "DOCTYPE":

 

guión runat = "server"

 

Public Sub Page_Load (ByVal Como remitente [objeto], ByVal e As EventArgs)

 

CS_NAME As [String] = "Prueba JavaScript"

 

Cs_type Dim As Type = Me. [GetType] ()

 

Csm dévil como ClientScriptManager = Page.ClientScript

 

Si no csm.IsStartupScriptRegistered (cs_type, CS_NAME) Entonces

 

Cs_text Dim As New StringBuilder ()

 

cs_text.Append ("script type = text / javascript alert ('Uso de JavaScript!') /")

 

cs_text.Append ("script")

 

csm.RegisterStartupScript (cs_type, CS_NAME, cs_text.ToString ())

 

End If

 

End Sub

 

/ Script

 

Agregue el código HTML para el resto de su página Web, guarde el archivo y cargarlo en el servidor para ejecutar el código JavaScript.

 

 

3 comentarios:

  1. Does your site have a contact page? I'm having a tough time locating it but, I'd like to send you
    an e-mail. I've got some recommendations for your blog you might be interested in hearing.
    Either way, great site and I look forward to seeing it expand over
    time.

    My website: self storage spaces

    ResponderEliminar
  2. Very soon this site will be famous among all blogging people, due to it's good articles

    Also visit my page ... winrar unlocker free download

    ResponderEliminar
  3. What's Going down i am new to this, I stumbled upon this I have discovered It positively useful and it has aided me out loads.
    I am hoping to give a contribution & assist other users
    like its aided me. Great job.

    Visit my page slitting

    ResponderEliminar