0

Hello

In my success.aspx file, I have:

<asp:Label ID="LblDate" runat="server" class="labelStyle" Text="Label"></asp:Label>

and

<div class="center">
<asp:Label ID="Name" runat="server"></asp:Label>  
you have successfully registered
</div>

and in my success.aspx.vb file, I have:

Code for the date, which works, and then:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        LblDate.Text = ReturnDate()

        If Request("Name") IsNot Nothing Then

            Name.Text = String.Format("{0}, ", Request("Name"))

        End If

    End Sub

Why would I be getting blue underlines under 'LblDate' and 'Name'. VS tells me that 'LblDate' is not declared. It may be
inaccessible due to its protection level (what 'protection level?), while for 'Name', I get: 'Name' is not declared.
File I/O functionality is available in the 'Microsoft.VisualBasic' namespace.

What do those errors mean, please, and how do I correct them?

3
Contributors
13
Replies
32
Views
2 Years
Discussion Span
Last Post by ggamble
0

Go into designer view, refresh and save the page, then go back into code view.

Sometimes the IDE is slow in writing to the .designer file.

Edited by ggamble: spelling

0

I have tried that and then closed down VS and restarted, but the errors are still there. Could it be anything to do with those Imports?

I have:

Imports Microsoft.AspNet.Identity
Imports Microsoft.AspNet.Identity.EntityFramework
Imports Microsoft.AspNet.Identity.Owin
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports Microsoft.Owin.Security
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Web.Security
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.Data.OleDb

Thanks again.

0

LblDate looks fine to me, unless you've modified some other parts of the file such as the class information (partial class). The aspx and aspx.vb are tied together by this partial class info.

Also I dont recognize this.. Request("Name"). What is this referring to? Do you have a subroutine called "Request"?

I know that on another thread you mentioned you were new to asp.net. If you get stuck and you want to try to fix your code without modifying what you have, just create another page and test your changes. that way, you dont loose what you have written already. If your new changes, work, copy over the code.

Edited by JorgeM

0

Hello Jorge

When a new user registers the Register.aspx.vb script redirects him to a personalised 'success' page:

 Dim target = String.Format("~/success.aspx?Name={0}", username.Text)
        ' Perform your Redirect '
        Response.Redirect(target, True)

that says 'Joe, you successfully registered', and so in my success.aspx file I have:

 <div class="center">
<asp:Label ID="Name" runat="server"></asp:Label>  
you have successfully registered
</div>

But 'Name' doesn't seem to be working and, in fact, I have just noticed that it doesn't like 'username' in that Redirect.

0

You are passing "Name" as a querystring parameter. To retreive the value on the target page you do so by...

 Request.QueryString

Edited by JorgeM

0

Thanks for your advice, Jorge. So, something like this where 'Name' is the ID of the Label?

Label.Name() = Request.QueryString["Name"];
0

Looks like you are running vb so it would be something like...

 Label.Name = Request.QueryString("Name");  

<edit>WRONG.. see my response below... JorgeM</edit>

this would work assuming your URL is something like.../success.aspx?Name=Blueie

Edited by JorgeM

0

Hello Jorge

Yes, I have:

 Dim target = String.Format("~/success.aspx?Name={0}", username.Text)
        'Redirect '
        Response.Redirect(target, True)
    End Sub

I will try it.

Thanks again!

0

I get an error there, Jorge:

   Label.Name = Request.QueryString("Name");

The error is with Label.Name: 'Name' is not a member of 'System.Web.UI.WebControls.Label'.

In my corresponding aspx file, I have:

<div class="center">

<asp:Label ID="Name" runat="server"></asp:Label>  
you have successfully registered
</div>

In my Imports, I have:

Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls

Should I change the ID if it doesn't like 'Name'?

0

Sorry, my mistake... your Label control's ID is called name, not label. it should be...

 Name.Text = Request.QueryString("Name");

I pretty much copied your text and pasted it in my response without taking the time to look at what I copied... sorry about that.

My last post deserves a down-vote :-(

You reference your controls in your code behind by ID and then in this case, we want access to its Text property.

Edited by JorgeM

0

Nooooooo! Not at all! You are very helpful.

Unfortunately, with

Name.Text = Request.QueryString("Name");

the error I get is that 'Text' is not a member of 'String'.

The problem seems to be deeper, doesn't it?

0

Hmmm. I'm not in front of a PC. Maybe Name is a keyword. Can you try using a different value for the iD, try... lblName

This topic has been dead for over six months. 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.