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

(Resolvido) Primeiros passos no .net


Clauido José

Pergunta

Como postei no tópico anteiro estou iniciando com asp.net então começei a fuçar na net e peguei um script no macoratti.net Validação usuando webmatrix , estou usando o vs2010 express bom ta dando um erro na pagina não sei qual é vou postar o codigo aqui ok.

<script language="VB" runat="server">
    Sub Valida()
        If (Page.IsValid) Then
            label1nome.Text = "Email valido"
        End If
    End Sub
</script>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <h2>primeiro projeto em asp.net</h2>        
    <form runat="server">
        <p>
            Digite seu email:<asp:TextBox ID="email" runat="server" Text="email"></asp:TextBox>
            <asp:RegularExpressionValidator
                ControlToValidate="email" 
                text="Email Valido" 
                ValidationExpression="\s@\s+\s(2,3)" 
                runat="server">
            </asp:RegularExpressionValidator>
        </p>
        <asp:Button ID="btValid" Text="validar" onclick="Valida" runat="server" />
        <asp:Label ID="label1nome" runat="server"></asp:Label>
    </form>
</asp:Content>

O erro que ta dando

Server Error in '/WebSite2' Application.

Content controls are allowed only in content page that references a master page.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Content controls are allowed only in content page that references a master page.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[HttpException (0x80004005): Content controls are allowed only in content page that references a master page.]System.Web.UI.MasterPage.CreateMaster(TemplateControl owner, HttpContext context, VirtualPath masterPageFile, IDictionary contentTemplateCollection) +8832886

System.Web.UI.Page.get_Master() +54

System.Web.UI.Page.ApplyMasterPage() +15

System.Web.UI.Page.PerformPreInit() +45

System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +328

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

Link para o comentário
Compartilhar em outros sites

6 respostass a esta questão

Posts Recomendados

  • 0

Desculpe é que sou iniciante na verdade estou uando o vs 2010 express e não tinha alterado a pagina defualt.aspx bom fiz do jeito que tava no site e agora até abre o form mas quando clico no enviar não faz nada e nem se quer da menssagem de erro, vou postar o ccodigo correto

If (Page.IsValid) Then
                labelnome.Text = "Email Invalido"
            End If
        End Sub
    </script>
    <body>
        <form onsubmit runat="server">
             Digite seu Email:<asp:TextBox ID="email" runat="server"></asp:TextBox>
             <asp:RegularExpressionValidator
                ControlToValidate="email"
                ValidationExpression = "\S+@\S+.\S{2,3}"
            runat="server"></asp:RegularExpressionValidator>
            <p>
                <asp:Button ID="btValidar" Text="validar"  runat="server" />
                <asp:Label ID="labelnome"  runat="server"></asp:Label>
            </p>
        </form>
    </body>
</html>

Link para o comentário
Compartilhar em outros sites

  • 0

Opa valeu pela dica desculpa ai resolvi mais essa falta de presta atançao coisa de iniciante kkk vou postar o codigo correto

<%@ Page Language="VB" %>

<html>
    <script language="VB" runat="server" >
        
        Sub validar(sender As Object, e As EventArgs)
            If (Page.IsValid) Then
                labelnome.Text = "Email valido"
            End If
        End Sub
    </script>
    <body>
        <form runat="server">
             Digite seu Email:<asp:TextBox ID="email" runat="server"></asp:TextBox>
             <asp:RegularExpressionValidator
                ControlToValidate="email"
                text="Email inválid !"
                ValidationExpression = "\S+@\S+.\S{2,3}"
            runat="server"></asp:RegularExpressionValidator>
            <p>
                <asp:Button ID="btValidar" Text="validar"  runat="server" OnClick="validar" />
                <asp:Label ID="labelnome"  runat="server"></asp:Label>
            </p>
        </form>
    </body>
</html>

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...