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!

Recommended Answers

All 4 Replies

Member Avatar for stbuchok

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

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.

Member Avatar for stbuchok

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.