Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6682369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:41:52+00:00 2026-05-26T04:41:52+00:00

My vb.net application needs to use a session variable. I don’t really know how

  • 0

My vb.net application needs to use a session variable. I don’t really know how to use it in ASP.net. I’ve been trying to use what my books have, but I can’t get this label to work. I need the user input to be validated against the database and if their code is in the database, the textbox should disappear and a label will appear saying Welcome.

The way I wrote it, I get an error saying the server tag is not well formed and in the codebehind it says that the ID of my label is not declared. Can anyone spot any problems with the code I wrote?

<asp:Label ID="lblIB" runat="server" DataSourceID="dsIBs" 
Text="Welcome, <%# Eval("First_Name") %> '&' <%# Eval("Last_Name")%>">
</asp:Label>


Protected Sub CustomValidator1_ServerValidate(ByVal source As Object, ByVal 
  args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles
  CustomValidator1.ServerValidate
    args.IsValid = True
    For Each drv As DataRowView In dsIBs.[Select](DataSourceSelectArguments.Empty)
        If drv("baccount").ToString() = args.Value Then
            args.IsValid = False
            lblIB.Visible = False
            Exit For
        End If
    Next

    If args.IsValid Then
        IBTextBox.Visible = False
        IBTextBoxButton.Visible = False
        lblIB.Visible = True
    End If
End Sub

UPDATE:

<asp:Label ID="lblIB" runat="server" Text=""></asp:Label>

    Protected Sub CustomValidator1_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles CustomValidator1.ServerValidate
    args.IsValid = True
    For Each drv As DataRowView In dsIBs.[Select](DataSourceSelectArguments.Empty)
        If drv("baccount").ToString() = args.Value Then
            args.IsValid = False
            lblIB.Visible = False
            Exit For
        End If
    Next

    If args.IsValid Then
        IBTextBox.Visible = False
        IBTextBoxButton.Visible = False
        lblIB.Visible = True
        lblIB.Text = String.Format("Welcome, {0} {1}", Session("FirstName"), Session("LastName"))

    End If
End Sub

UPDATE 2:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) 
Handles Me.Load
    lblIB.Visible = False
End Sub


If args.IsValid Then
   IBTextBox.Visible = False
   IBTextBoxButton.Visible = False
   lblIB.Visible = True
   lblIB.Text = String.Format("Welcome, {0} {1}", Session("FirstName"),
   Session("LastName"))

    Protected Sub IBTextBoxButton_Click(ByVal sender As Object, ByVal e As 
    System.EventArgs) Handles IBTextBoxButton.Click
    Session("IB") = IBTextBox.Text
    Dim IB As String = Session("IB")
    Response.Redirect(Request.RawUrl + "&IB=" + Session("IB"))
End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T04:41:53+00:00Added an answer on May 26, 2026 at 4:41 am

    Your markup is wrong because the Label control doesn’t have a DataSourceID property, so you should remove it:

    <asp:Label ID="lblIB" runat="server" 
    Text="Welcome, <%# Eval("First_Name") %> '&' <%# Eval("Last_Name")%>">
    </asp:Label>
    

    I would also remove the Eval expression (unless it’s inside a databound control -gridview, etc-) in the Text property and leave it as:

    <asp:Label ID="lblIB" runat="server" 
    Text="">
    </asp:Label>
    

    Finally, you should be able to perform your validation on the server side and set the Text programmatically doing something like:

    lblIB.Text = "Welcome " + First_Name + " " + Last_Name
    

    Where First_Name and Last_Name are read from the database somehow.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose you have two seperate ASP.NET Web Application projects that both need to use
We have an asp.net application that needs to be expanded to notify users when
I have an ASP.NET web application where a portion of it needs to run
I'm working on a multi-tenant ASP.NET MVC application. So far we have been using
Can anyone tell me that if I use Session(inside an ASP.NET MVC 3 application)
I am creating a .NET application (C#) that needs to use a lot of
I use a System.Timers.Timer in my Asp.Net application and I need to use the
I need to use a dll in my asp.net application. How do I load
I need my ASP.NET web application to use silverlight controls in my web page.
My ASP.NET application needs a number of supporting services to run periodically in the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.