0

I have some code-behind and I am running in to an error. I am still very new to ASP.NET so I am having difficulty figuring out the "identifier expected" error.

Here is my code:

Partial Class Comments2
    Inherits System.Web.UI.Page

    Protected Sub 
    Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
    HiddenField hidDate = (HiddenField)FormView1.FindControl("hidTimeDate");
	hidDate.Value = DateTime.Now.ToString();

    End Sub
End Class

Thank you for any help!

2
Contributors
4
Replies
7
Views
6 Years
Discussion Span
Last Post by rosiec
0

This looks like it is supposed to be VB.Net, if so why do you have ";" at the end of the lines?

The code was originally C# and I'm trying to convert it to VB. Like I said, not a ton of experience with either. I took the semi-colons out, but that doesn't fix my identifier problem.

0

Try this (Completely untested):

Partial Class Comments2 Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        HiddenField hidDate = (HiddenField)FormView1.FindControl("hidTimeDate")
	hidDate.Value = DateTime.Now.ToString()
    End Sub
End Class
0

Thanks. I was messing around with it for a bit and managed to get to that. Unfortunately, I now have a new error:

Compiler Error Message: BC30108: 'HiddenField' is a type and cannot be used as an expression.

Also, in my code editor, "HiddenField", "hidDate" and "FormView" are all underlined with blue squiggles. Putting Parentheses around HiddenField and hidDate got rid of those (so it read (HiddenField hidDate = (HiddenField)FormView1...), but now it says my first parentheses is a syntax error.

I'm kinda in over my head, but I need to complete this project, so all your help is much appreciated.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.