Jump to content
Fórum Script Brasil
  • 0

Tem Como Fazer Isso?


Question

Olá pessoal...

tem como fazer isso você declarar uma variavel com valor entre <script></script> e depois mostrar esse valor nas <% %>

se tiver como posta ai.. o metodo certo de fazer... beleza

<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="iso-8859-1" %>

<script language="c#" runat="server">

public void Page_Load(){

teste = "Olá Mundo";

}

</script>

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

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

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Untitled Document</title>

</head>

<body>

<%=teste%>

</body>

</html>

Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Tem sim, mas no Asp.net é diferente do PHP, Você deve declarar o tipo da váriavel e depois passar o seu valor para uma label através do parâmetro Text desta label. E então colocar no código HTML esta label.

Segue abaixo o exemplo. ( Espero ter sido útil)

<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="iso-8859-1" %>

<script language="c#" runat="server">

public void Page_Load(){

string teste = "Olá Mundo";

lblTeste.Text = teste;

}

</script>

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

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

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Untitled Document</title>

</head>

<body>

<asp:Label ID="lblTeste" runat="server"></asp:Label>

</body>

</html>

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      148735
    • Total Posts
      644602
×
×
  • Create New...