Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

asp.net

O que tem de errado ai.

Recommended Posts

Tenho o código abaixo feito no webMatrix.<%@ Page Language="VB" %><script runat="server"> ' Insert page code here ' Sub Page_Load(sender As Object, e As EventArgs) lb1.Text = Date() End Sub </script><html><head></head><body> <form runat="server"> <asp:Label id="lb1" runat="server"></asp:Label> <!-- Insert content here --> </form></body></html> Mas quando tempo executar o script tenho como resposta o seguinte mensagem. Server Error in '/' Application. --------------------------------------------------------------------------------Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: BC30108: 'Date' is a type, and so is not a valid expression.Source Error: Line 6: Line 7: Sub Page_Load(sender As Object, e As EventArgs)Line 8: lb1.Text = Date()Line 9: End SubLine 10: Source File: C:\Documents and Settings\Guilherme\Meus documentos\testedata.aspx Line: 8 Show Detailed Compiler Output: C:\Documents and Settings\Guilherme> "c:\windows\microsoft.net\framework\v1.1.4322\vbc.exe" /t:library /utf8output /R:"c:\windows\assembly\gac\system.drawing.0.5000.0__b03f5f7f11d50a3a\system.drawing.dll" /R:"c:\windows\assembly\gac\system.web.0.5000.0__b03f5f7f11d50a3a\system.web.dll" /R:"c:\windows\assembly\gac\system.0.5000.0__b77a5c561934e089\system.dll" /R:"c:\windows\assembly\gac\system.web.services.0.5000.0__b03f5f7f11d50a3a\system.web.services.dll" /R:"c:\windows\assembly\gac\system.xml.0.5000.0__b77a5c561934e089\system.xml.dll" /R:"c:\windows\assembly\gac\system.web.mobile.0.5000.0__b03f5f7f11d50a3a\system.web.mobile.dll" /R:"c:\windows\assembly\gac\system.enterpriseservices.0.5000.0__b03f5f7f11d50a3a\system.enterpriseservices.dll" /R:"c:\windows\assembly\gac\system.data.0.5000.0__b77a5c561934e089\system.data.dll" /out:"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\root\d9049df9\e82a919c\cztzfuwd.dll" /debug- "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\root\d9049df9\e82a919c\cztzfuwd.0.vb" Microsoft ® Visual Basic .NET Compiler version 7.10.3052.4for Microsoft ® .NET Framework version 1.1.4322.573Copyright © Microsoft Corporation 1987-2002. All rights reserved. C:\Documents and Settings\Guilherme\Meus documentos\testedata.aspx(8) : error BC30108: 'Date' is a type, and so is not a valid expression. lb1.Text = Date() ~~~~ C:\Documents and Settings\Guilherme\Meus documentos\testedata.aspx(8) : error BC30287: '.' expected. lb1.Text = Date() ~ Show Complete Compilation Source: Line 1: '------------------------------------------------------------------------------Line 2: ' <autogenerated>Line 3: ' This code was generated by a tool.Line 4: ' Runtime Version: 1.1.4322.573Line 5: 'Line 6: ' Changes to this file may cause incorrect behavior and will be lost if Line 7: ' the code is regenerated.Line 8: ' </autogenerated>Line 9: '------------------------------------------------------------------------------Line 10: Line 11: Option Strict OffLine 12: Option Explicit OnLine 13: Line 14: Imports Microsoft.VisualBasicLine 15: Imports SystemLine 16: Imports System.CollectionsLine 17: Imports System.Collections.SpecializedLine 18: Imports System.ConfigurationLine 19: Imports System.TextLine 20: Imports System.Text.RegularExpressionsLine 21: Imports System.WebLine 22: Imports System.Web.CachingLine 23: Imports System.Web.SecurityLine 24: Imports System.Web.SessionStateLine 25: Imports System.Web.UILine 26: Imports System.Web.UI.HtmlControlsLine 27: Imports System.Web.UI.WebControlsLine 28: Line 29: Namespace ASPLine 30: Line 31: Public Class testedata_aspxLine 32: Inherits System.Web.UI.PageLine 33: Implements System.Web.SessionState.IRequiresSessionStateLine 34: Line 35: Private Shared __autoHandlers As IntegerLine 36: Line 37: Line 38: #ExternalSource("C:\Documents and Settings\Guilherme\Meus documentos\testedata.aspx",17)Line 39: Protected lb1 As System.Web.UI.WebControls.LabelLine 40: Line 41: #End ExternalSourceLine 42: Line 43: Line 44: #ExternalSource("C:\Documents and Settings\Guilherme\Meus documentos\testedata.aspx",16)Line 45: Private __control2 As System.Web.UI.HtmlControls.HtmlFormLine 46: Line 47: #End ExternalSourceLine 48: Line 49: Private Shared __initialized As Boolean = falseLine 50: Line 51: Private Shared __fileDependencies As System.Collections.ArrayListLine 52: Line 53: Line 54: #ExternalSource("C:\Documents and Settings\Guilherme\Meus documentos\testedata.aspx",2)Line 55: Line 56: Line 57: ' Insert page code hereLine 58: 'Line 59: Line 60: Sub Page_Load(sender As Object, e As EventArgs)Line 61: lb1.Text = Date()Line 62: End SubLine 63: Line 64: Line 65: #End ExternalSourceLine 66: Line 67: Public Sub New()Line 68: MyBase.NewLine 69: Dim dependencies As System.Collections.ArrayListLine 70: If (ASP.testedata_aspx.__initialized = false) ThenLine 71: dependencies = New System.Collections.ArrayListLine 72: dependencies.Add("C:\Documents and Settings\Guilherme\Meus documentos\testedata.aspx")Line 73: ASP.testedata_aspx.__fileDependencies = dependenciesLine 74: ASP.testedata_aspx.__initialized = trueLine 75: End IfLine 76: End SubLine 77: Line 78: Protected Overrides Property AutoHandlers As IntegerLine 79: GetLine 80: Return ASP.testedata_aspx.__autoHandlersLine 81: End GetLine 82: SetLine 83: ASP.testedata_aspx.__autoHandlers = valueLine 84: End SetLine 85: End PropertyLine 86: Line 87: Protected ReadOnly Property ApplicationInstance As System.Web.HttpApplicationLine 88: GetLine 89: Return CType(Me.Context.ApplicationInstance,System.Web.HttpApplication)Line 90: End GetLine 91: End PropertyLine 92: Line 93: Public Overrides ReadOnly Property TemplateSourceDirectory As StringLine 94: GetLine 95: Return "/"Line 96: End GetLine 97: End PropertyLine 98: Line 99: Private Function __BuildControllb1() As System.Web.UI.ControlLine 100: Dim __ctrl As System.Web.UI.WebControls.LabelLine 101: Line 102: #ExternalSource("C:\Documents and Settings\Guilherme\Meus documentos\testedata.aspx",17)Line 103: __ctrl = New System.Web.UI.WebControls.LabelLine 104: Line 105: #End ExternalSourceLine 106: Me.lb1 = __ctrlLine 107: Line 108: #ExternalSource("C:\Documents and Settings\Guilherme\Meus documentos\testedata.aspx",17)Line 109: __ctrl.ID = "lb1"Line 110: Line 111: #End ExternalSourceLine 112: Return __ctrlLine 113: End FunctionLine 114: Line 115: Private Function __BuildControl__control2() As System.Web.UI.ControlLine 116: Dim __ctrl As System.Web.UI.HtmlControls.HtmlFormLine 117: Line 118: #ExternalSource("C:\Documents and Settings\Guilherme\Meus documentos\testedata.aspx",16)Line 119: __ctrl = New System.Web.UI.HtmlControls.HtmlFormLine 120: Line 121: #End ExternalSourceLine 122: Me.__control2 = __ctrlLine 123: Dim __parser As System.Web.UI.IParserAccessor = CType(__ctrl,System.Web.UI.IParserAccessor)Line 124: Line 125: #ExternalSource("C:\Documents and Settings\Guilherme\Meus documentos\testedata.aspx",16)Line 126: __parser.AddParsedSubObject(New System.Web.UI.LiteralControl(""&Microsoft.VisualBasic.ChrW(13)&Microsoft.VisualBasic.ChrW(10)&" "))Line 127: Line 128: #End ExternalSourceLine 129: Line 130: #ExternalSource("C:\Documents and Settings\Guilherme\Meus documentos\testedata.aspx",16)Line 131: Me.__BuildControllb1Line 132: Line 133: #End ExternalSourceLine 134: Line 135: #ExternalSource("C:\Documents and Settings\Guilherme\Meus documentos\testedata.aspx",16)Line 136: __parser.AddParsedSubObject(Me.lb1)Line 137: Line 138: #End ExternalSourceLine 139: Line 140: #ExternalSource("C:\Documents and Settings\Guilherme\Meus documentos\testedata.aspx",16)Line 141: __parser.AddParsedSubObject(New System.Web.UI.LiteralControl(""&Microsoft.VisualBasic.ChrW(13)&Microsoft.VisualBasic.ChrW(10)&" <!-- Insert content here -->"&Microsoft.VisualBasic.ChrW(13)&Microsoft.VisualBasic.ChrW(10)&" "))Line 142: Line 143: #End ExternalSourceLine 144: Return __ctrlLine 145: End FunctionLine 146: Line 147: Private Sub __BuildControlTree(ByVal __ctrl As System.Web.UI.Control)Line 148: Dim __parser As System.Web.UI.IParserAccessor = CType(__ctrl,System.Web.UI.IParserAccessor)Line 149: Line 150: #ExternalSource("C:\Documents and Settings\Guilherme\Meus documentos\testedata.aspx",1)Line 151: __parser.AddParsedSubObject(New System.Web.UI.LiteralControl(""&Microsoft.VisualBasic.ChrW(13)&Microsoft.VisualBasic.ChrW(10)&"<html>"&Microsoft.VisualBasic.ChrW(13)&Microsoft.VisualBasic.ChrW(10)&"<head>"&Microsoft.VisualBasic.ChrW(13)&Microsoft.VisualBasic.ChrW(10)&"</head>"&Microsoft.VisualBasic.ChrW(13)&Microsoft.VisualBasic.ChrW(10)&"<body>"&Microsoft.VisualBasic.ChrW(13)&Microsoft.VisualBasic.ChrW(10)&" "))Line 152: Line 153: #End ExternalSourceLine 154: Line 155: #ExternalSource("C:\Documents and Settings\Guilherme\Meus documentos\testedata.aspx",1)Line 156: Me.__BuildControl__control2Line 157: Line 158: #End ExternalSourceLine 159: Line 160: #ExternalSource("C:\Documents and Settings\Guilherme\Meus documentos\testedata.aspx",1)Line 161: __parser.AddParsedSubObject(Me.__control2)Line 162: Line 163: #End ExternalSourceLine 164: Line 165: #ExternalSource("C:\Documents and Settings\Guilherme\Meus documentos\testedata.aspx",1)Line 166: __parser.AddParsedSubObject(New System.Web.UI.LiteralControl(""&Microsoft.VisualBasic.ChrW(13)&Microsoft.VisualBasic.ChrW(10)&"</body>"&Microsoft.VisualBasic.ChrW(13)&Microsoft.VisualBasic.ChrW(10)&"</html>"&Microsoft.VisualBasic.ChrW(13)&Microsoft.VisualBasic.ChrW(10)))Line 167: Line 168: #End ExternalSourceLine 169: End SubLine 170: Line 171: Protected Overrides Sub FrameworkInitialize()Line 172: Me.__BuildControlTree(Me)Line 173: Me.FileDependencies = ASP.testedata_aspx.__fileDependenciesLine 174: Me.EnableViewStateMac = trueLine 175: Me.Request.ValidateInputLine 176: End SubLine 177: Line 178: Public Overrides Function GetTypeHashCode() As IntegerLine 179: Return 923380422Line 180: End FunctionLine 181: End ClassLine 182: End NamespaceLine 183: --------------------------------------------------------------------------------Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573

Compartilhar este post


Link para o post
Compartilhar em outros sites

date() foi interpletado como um sub

 

faz assim

 

 

 

<script language="VB" runat="server">Sub page_load()date.text=Day(Now) & ":" & Month(Now) & ":" & year(Now)End Sub</script><html><Title>Testando o asp.net</title><body>   <form runat="server">     <asp:label id="date" runat="server" /></form></Body></html>

 

 

t+

Compartilhar este post


Link para o post
Compartilhar em outros sites

Ocorre o seguinte:ASP.NET é orientado a objeto, portanto deve-se instanciar uma classe para se obter a data.

cara não tem nada haver o c... com as calças, falou besteira, hehet+

Compartilhar este post


Link para o post
Compartilhar em outros sites

kra olha o que funfo pra mim,

 

Explicação:

 

se falei besteira eh que sou novo em asp.net hauhauah

 

<%@ Page Language="VB" %>

<script runat="server">

 

Sub page_load()

 

TextBox1.text=Day(Now) & ":" & Month(Now) & ":" & year(Now)

 

 

End Sub

 

ASP [/tr][tr]</script>

<html>

<head>

</head>

<body>

<form runat="server">

<p>

Quero a data de hoje :

<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>

</p>

<p>

<!-- Insert content here -->

</p>

</form>

</body>

</html>

[/tr]

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.