Results 1 to 4 of 4

Thread: [RESOLVED] [2008] When to use "ASP" vs VB Code

  1. #1

    Thread Starter
    Fanatic Member The_Grudge's Avatar
    Join Date
    Jan 2005
    Location
    Canada
    Posts
    836

    Resolved [RESOLVED] [2008] When to use "ASP" vs VB Code

    I created a little web-app today that has a login screen and takes you to a new page if you enter the correct user/password combo.

    It works great but I'm sort of confused as to when I should use code in ASP vs when I should put it in my .vb file.

    Take for example the username. Upon a successful login I wanted a label on the next page to provide the name of the person currently logged in. I did this using the "login name" control but I imagine there is a way to do it via .NET code as well...such as creating a label and saying Label1.Text = USERNAME (or whatever the syntax happens to be...I'm not sure).

    Do you see what I'm getting at? If I can do something using both methods, which is better?

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [2008] When to use "ASP" vs VB Code

    Hey there,

    Yes, you would be able to do what you suggest, i.e.

    Code:
    Label1.Text = HttpContext.Current.User.Identity.Name;
    This could be done on the page load event in order to make that name appear on the page. However, as you have described, the LoginName control does this for you. This is a server control that is embedded in the aspx page, and on load the property of this control is set.

    Gary

  3. #3
    Fanatic Member
    Join Date
    Feb 2006
    Posts
    592

    Re: [2008] When to use "ASP" vs VB Code

    if you were using asp.net version prior to ASP.NET 2.0 invariably you had to create it all yourself which means you had to do the things programatically.
    fortunatelly asp.net brought us a series of APIs, controls, and providers that enable you to control an application’s user membership and role management. Using these APIs, you can easily manage users and their complex roles — creating, deleting, and editing them. You get all this capability by using the APIs or a built-in Web tool called the Web Site Administration Tool.
    Simply find a good book or good article about the LOGIN controls and you'll figure out how easy it is.
    http://msdn.microsoft.com/en-us/library/ms178329.aspx
    http://quickstarts.asp.net/QuickStar...n/default.aspx
    http://quickstart.developerfusion.co...gin/login.aspx

    Most of the things are built-in so you will have to code very few lines to achieve what you want.

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2008] When to use "ASP" vs VB Code

    Quote Originally Posted by The_Grudge
    I created a little web-app today that has a login screen and takes you to a new page if you enter the correct user/password combo.

    It works great but I'm sort of confused as to when I should use code in ASP vs when I should put it in my .vb file.

    Take for example the username. Upon a successful login I wanted a label on the next page to provide the name of the person currently logged in. I did this using the "login name" control but I imagine there is a way to do it via .NET code as well...such as creating a label and saying Label1.Text = USERNAME (or whatever the syntax happens to be...I'm not sure).

    Do you see what I'm getting at? If I can do something using both methods, which is better?
    I see what you're saying - you are wondering whether you are relying too much on the ASP.NET controls in your web applications. You have to keep in mind that the controls provided to you in ASP.NET such as the Login Control, Login Name control, SiteMapPath control, etc. are essentially controls which encapsulate what you would normally do anyways - put a literal there, write the user's name into it. So you're good to use the controls provided - it's only providing you with a control to do what is most commonly done in web applications today, in a somewhat flexible manner to appeal to most developers.

    Of course, not all applications have requirements that are met by the provided membership controls and this is where you'd either create your own control or 'extend' the existing ones.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width