Ir para conteúdo
Fórum Script Brasil
  • 0

Cores.net


Denis Bittencourt Muniz

Pergunta

Fala galera!

Alguém ai pode analisar meu código e falar aonde estou errando?:

<% @ Page Language = "C#" %>


<script runat="server">
void Imprimir(Object Sender, EventArgs e){

	Rotulo.ForeColor = CorFonte.SelectedItem.Text; //Deu erro!

	Rotulo.Text = Texto.Text;

}
</script>

<html>

<head>
<title>Repetição</title>
</head>

<body>

<form runat="server" >

<asp:Label runat="server"  id="Rotulo"><b>Seja bem-vindo!!</b></asp:Label><p>

<b>Texto:</b>&nbsp; <asp:TextBox runat="server" id="Texto"  />&nbsp;&nbsp;&nbsp

<b>Cor da fonte:</b>&nbsp; 
<asp:DropDownList runat="server" id="CorFonte">
<asp:ListItem Value="Black">Preto</asp:ListItem>
<asp:ListItem Value="White">Branco</asp:ListItem>
<asp:ListItem Value="Red">Vermelho</asp:ListItem>
<asp:ListItem Value="Blue">Azul</asp:ListItem>
<asp:ListItem Value="Yellow">Amarelo</asp:ListItem>
<asp:ListItem Value="Green">Verde</asp:ListItem>
<asp:ListItem Value="Orange">Laranja</asp:ListItem>
<asp:ListItem Value="Purple">Roxo</asp:ListItem>
<asp:ListItem Value="Cyan">Ciano</asp:ListItem>
<asp:ListItem Value="Brown">Marrom</asp:ListItem>
</asp:DropDownList>&nbsp;&nbsp;&nbsp

<b>Cor do fundo:</b>&nbsp; 
<asp:DropDownList runat="server" id="CorFundo">
<asp:ListItem Value="Black">Preto</asp:ListItem>
<asp:ListItem Value="White">Branco</asp:ListItem>
<asp:ListItem Value="Red">Vermelho</asp:ListItem>
<asp:ListItem Value="Blue">Azul</asp:ListItem>
<asp:ListItem Value="Yellow">Amarelo</asp:ListItem>
<asp:ListItem Value="Green">Verde</asp:ListItem>
<asp:ListItem Value="Orange">Laranja</asp:ListItem>
<asp:ListItem Value="Purple">Roxo</asp:ListItem>
<asp:ListItem Value="Cyan">Ciano</asp:ListItem>
<asp:ListItem Value="Brown">Marrom</asp:ListItem>
</asp:DropDownList>&nbsp;&nbsp;&nbsp

<asp:CheckBox runat="server" id="Negrito" Text="<b>Negrito</b>" />&nbsp;
<asp:CheckBox runat="server" id="Italico" Text="<i>Itálico</i>" />&nbsp;
<asp:CheckBox runat="server" id="Sublinhado" Text="<u>Sublinhado</u>" />&nbsp;
<asp:CheckBox runat="server" id="tachado" Text="<s>Tachado</s>" />&nbsp;&nbsp;

<asp:LinkButton runat="server" id="Enviar" Text="Enviar" OnClick="Imprimir" />

</form>

</body>

</html>

Como trabalhar com cores?

falows!

Link para o comentário
Compartilhar em outros sites

1 resposta a esta questão

Posts Recomendados

  • 0

A mensagem de erro é:

Cannot implicitly convert type 'string' to 'System.Drawing.Color'

Ou seja:

Não se pode converter implicitamente o tipo "string" para "System.Drawing.Color"

Então, você tem que fazer isso (naquela linha):

Rotulo.ForeColor = System.Drawing.Color.FromName(CorFonte.SelectedItem.Text);

Certo? wink.gif

Graymalkin

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.


  • Estatísticas dos Fóruns

    • Tópicos
      152,2k
    • Posts
      652k
×
×
  • Criar Novo...