Expression does not produce a value: Session error?

A

antonyliu2002

I have the following simple code to test if my session is working:

<Script Runat="Server">
Sub LinkButtonGenInfo_Click(s As Object, e As EventArgs)
If txtFirstName.Text <> Nothing Then
Session("firstName")=txtFirstName.Text
End If

If txtFirstName.Text <> Nothing Then
lblYourName.Text=Response.Write(Session("firstName"))
End If
End Sub
</Script>

When I check out the page from the browser, I got the following error
message at Line 10, and I don't know how to fix it. Could you please
give me a hint? Thanks a lot!

Compiler Error Message: BC30491: Expression does not produce a value.

Source Error:

Line 8: End If
Line 9: If txtFirstName.Text <> Nothing Then
Line 10: lblYourName.Text=Response.Write(Session("firstName"))
Line 11: End If
Line 12: End Sub
 
M

Marina

Response.Write is a Sub (to use VB terminology). As such, it does not return
a value. Since it does not return a value, you cannot assign the result of
executing this method to a property or variable.
 
J

John Timney \(ASP.NET MVP\)

lblYourName.Text=Session("firstName")


--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director
 
A

antonyliu2002

Oh, gosh, the stupid mistake I made makes me blush. But, please
understand that it's been quite a while since I programmed last time.

Thanks a lot, Marina and John who offered the solution.
 
A

antonyliu2002

Oh, gosh, the stupid mistake I made makes me blush. But, please
understand that it's been quite a while since I programmed last time.

Thanks a lot, Marina and John who offered the solution.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top