• 0
Sign in to follow this  
Clauido José

(Resolvido) Primeiros passos no .net

Question

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="\[email protected]\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

Share this post


Link to post
Share on other sites

6 answers to this question

Recommended Posts

  • 0

O código html do site do macoratti não tem nada a ver com o seu, o erro é algo nas suas páginas que esta diferente da Master.Page.

Poste o código da sua Master.Page.

Abraços...

Share this post


Link to post
Share on other sites
  • 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 = "\[email protected]\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>

Share this post


Link to post
Share on other sites
  • 0

Você quis dizer o botão Validar? Não vi nenhum botão enviar.

O seu botão validar não esta a associado a nenhum evento.

Abraços...

Share this post


Link to post
Share on other 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 = "\[email protected]\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>

Share this post


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.

Sign in to follow this