locked
Display user name in the header when logged in RRS feed

  • Question

  • User1806461582 posted

    How do I display user name in the header when logged in? (right above the log out) I am assuming in the master page but I did not see any  header.aspx. Please help. need some direction. Also, few lines of code will be appreciated it too.

    Sunday, January 4, 2009 5:33 PM

Answers

  • User-1760427068 posted

     I believe there is a good chance this post will be marked as resolved the next time the original poster looks at what has been added.  Of course anyone is welcome to read on and comment.

    -----------------------

    I think the code below does it (and I will check it).  Do you use C#?

    MembershipUser membershipUser = Membership.GetUser();
    if (membershipUser != null)
    {
        string loggedinuser = Membership.GetUser().ToString();
        yourdiv.InnerHtml = loggedinuser;
    }

    for the above to work you need

    using System.Web.Security; // this enables Membership

    I'm assuming that you want to place the username somewhere and you have a way of doing it like with a div or a span or a label.  Is this correct?

    -Larry

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, January 4, 2009 8:35 PM
  • User-1760427068 posted

    Because the answer is "You can put it anywhere" (and that sounds vague and evasive) I'm going to try a different strategy.  I built a web site that has four pages (a masterpage and three more pages: Default.aspx, Login.aspx, AnotherPage.aspx).  I'm showing all four pages below, using a single line of asterisks between aspx and aspx.cs  and using four lines of asterisks between pages.  A post after this will discuss what to look for:

    • ***MasterPage.master
    • **************************************
    • **************************************
    • ************************************** 
      <%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
      
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      
      <html xmlns="http://www.w3.org/1999/xhtml">
      <head runat="server">
          <title></title>
          
          <style type="text/css" media="all">
          #topline {background-color: #DDF;}
          #maincontent {background-color: #FF8;}
          #bottomline {background-color: #F99;}
          </style>
          
          <asp:ContentPlaceHolder id="head" runat="server">
          </asp:ContentPlaceHolder>
      </head>
      <body>
          <form id="form1" runat="server">
          
              <div id="topline">
      
              <span id="spanid" runat="server" />
              <div id="divid" runat="server" />
              <asp:Label ID="Labelid" runat="server" Text="You need to login..."></asp:Label>
              
              </div>
              
              <br /><br />
              
              <div id="maincontent">
              <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
              
              </asp:ContentPlaceHolder>
              </div>
              
              <div id="bottomline">
              <p>I went to the ASP.NET Web Site Administration Tool and went to Security and for Select Authentication type I 
              changed it to 'From the internet'.</p>
              <p>That was the only change I made at the Web Site Administration Tool.</p>
              </div>
      
          </form>
      </body>
      </html>

    *****************************************

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.Security; // this enables Membership
    
    
    public partial class MasterPage : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            MembershipUser membershipUser = Membership.GetUser();
            if (membershipUser != null)
            {
                string loggedinuser = Membership.GetUser().ToString();
                divid.InnerHtml = "divid username: " + loggedinuser;
                spanid.InnerHtml = "spanid username: " + loggedinuser;
                Labelid.Text = "Labelid username: " + loggedinuser;
            }
            else
            {
                Labelid.Text = "I went through protected void Page_Load and membershipUser was null, sorry!";
            }
        }
    }
     
    • ***Default.aspx
    • **************************************
    • **************************************
    • ************************************** 
      <%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
      
      <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
      </asp:Content>
      <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
      <p>This is the Default.aspx page.</p>
      <p>Now go to <a href="AnotherPage.aspx">AnotherPage.aspx</a></p>
      </asp:Content

    *********************************

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
    
        }
    }
     
    • ***Login.aspx
    • **************************************
    • **************************************
    • ************************************** 
      <%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Login" %>
      
      <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
      </asp:Content>
      <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
      
          <table><tr>
      
          <td>
      
          <asp:Login ID="Login1" runat="server">
          </asp:Login>
          
              <asp:LoginStatus ID="LoginStatus1" runat="server" />
          
          </td>
          <td width="50"></td>
          <td>
          
          <asp:CreateUserWizard ID="CreateUserWizard1" runat="server">
              <WizardSteps>
                  <asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server">
                  </asp:CreateUserWizardStep>
                  <asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server">
                  </asp:CompleteWizardStep>
              </WizardSteps>
          </asp:CreateUserWizard>
          
          </td>
          
          </tr><table>
          
          
              <p>Now go to <a href="AnotherPage.aspx">AnotherPage.aspx</a>.</p>
      
      </asp:Content>

    *****************************************

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
    
        }
    }
     
    • ***AnotherPage.aspx
    • **************************************
    • **************************************
    • ************************************** 
      <%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="AnotherPage.aspx.cs" Inherits="AnotherPage" %>
      
      <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
      </asp:Content>
      <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
      
      <p>This is another page.</p>
      <p>Go back to the <a href="Login.aspx">Login page</a> and log out.</p>
      
      </asp:Content>

    *********************************

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    public partial class AnotherPage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
    
        }
    }
     
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 5, 2009 8:32 PM
  • User-1760427068 posted

    Admittedly, it's going to be tedious to build the four pages above to prove the example.  I estimate about 5 minutes of work to build the example.  However, after the example is created you will have a model system to which you can make alterations to see what happens as a result of the changes.

    It doesn't matter whether you use div or span or textbox so I thought, why not put in all three and prove it.

    Next, we needed several pages.  You said masterpage so I wanted this example to show that if you build the feature on the masterpage you'll never have to write anything about it on any other page.  I could have just said that, and it probably would have made sense, but it will be more real when you see it.

    We built the Default.aspx page next because if you didn't have it at some point the program would look for it and if it wasn't there you would get a white screen, and that causes panic.

    We then built the Login.aspx page (which also has a register tool) so that you can login and see how the line at the top changes.  The Login.aspx page also has a tool for logout.  This is helpful because you can login and logout and verify that the upper line is mirroring the changes without fail.

    I mentioned on the masterpage what I did with the Web Site Administration Tool (look for the hammer and world icon under Solution explorer--it's the icon furthest to the right--at least this is true for Visual Web Developer.  This note was also built there to fill space in the part that is the bottomline div on the masterpage.

    Note that we built three different div areas with three different colors.    This takes us back to the original question "where should I put it?  or in this case, where should I put them?"

    Once you are satisfied that the example works (with "them" in the blue area) move "them" to another place on the masterpage and then test the different pages again.  I think after you have moved it to three different places you will be convinced that it doesn't matter--and I think as an indirect benefit you will have a higher confidence for what you can do with a masterpage which will benefit you when you work with future designs.

    Given the amount of time that I put into building this, and the amount of time that you put into making it, I would recommend that you tell me after you have finished this, and maybe we use this example to do a few more things (it is important to mark the post as resolved and issue points both to show good faith and also because other persons seeing a "Not Resolved" and coming here and finding it resolved (after reading for five minutes) will feel something bad and I don't want any of them to be unhappy about wasting the five minutes.

    for my notes- this project is "TestLogin"

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 5, 2009 8:47 PM
  • User1806461582 posted

    wow. great answers in detail. I will try your sample tonight and give you the feedback. and will mark this post completed.

    Thanks a lotttttt.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 6, 2009 3:19 PM
  • User555306248 posted

    You can use this code

    MembershipUser membershipUser = Membership.GetUser();
    if (membershipUser != null)
    {
        string loggedinuser = Membership.GetUser().ToString();
        yourdiv.InnerHtml = loggedinuser;
    }

    also there is another option to get user name

    HttpContext.Current.User.Identity

    http://msdn.microsoft.com/en-us/library/system.web.httpcontext.user.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 6, 2009 10:30 PM
  • User1806461582 posted

    Great job guys. It worked like charm. I am going to elaborate which order they need to take place.

    step1: Add a Label right above <div login> area in masterpage.master page. Lets call that lblShowUser
    step2: on load for masterpage.master.cs page put this code

         MembershipUser
    membershipUser = Membership.GetUser();
                if (membershipUser != null)
                   {
                     
    string loggedinuser = Membership.GetUser().ToString();
                      lblShowUser.Text =
    "Welcome " + loggedinuser;
                   }
                  
    else
                  
    {
                      lblShowUser.Text =
    "";
                   }

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 6, 2009 11:33 PM
  • User-635250172 posted

    Bulding off this code, I put this code in my master page:

      

    1    <div id="userLoggedIn" runat="server">
    2    </div>
    

     

    Then in my Page_Load method, I put this code: 

    1            // if user is logged in, set the innerhtml of the userLoggedIn div to show the user name
    2            // else, set the text telling the user how to log in.
    3            if (System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
    4            {
    5                string userName = "<p>Hello, " + System.Web.HttpContext.Current.User.Identity.Name +
    6                    "! Not you? <a href=\"Default.aspx\">Click here to log in.</a><p>";
    7                userLoggedIn.InnerHtml = userName;
    8            }
    9            else
    10           { 
    11               string userName = "<p><a href=\"week2.aspx\">Click here to log in.</a><p>";
    12               userLoggedIn.InnerHtml = userName; 
    13           }
    

     

    Now the user name displays when the user is logged in.

    Thank you for answering this guy's questions. :)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, February 22, 2009 2:59 AM
  • User1806461582 posted

     quickest way to do it use session state to store name. (of course, u should b using stored procedure to do this).

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 25, 2009 7:32 PM
  • User555306248 posted

     Afetr authenticating the user, store that user name in Session. Add label t Master Page then set the text to it

    Label.Text = Session["UserName"].ToString();

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 25, 2009 11:24 PM

All replies

  • User-1760427068 posted

     I believe there is a good chance this post will be marked as resolved the next time the original poster looks at what has been added.  Of course anyone is welcome to read on and comment.

    -----------------------

    I think the code below does it (and I will check it).  Do you use C#?

    MembershipUser membershipUser = Membership.GetUser();
    if (membershipUser != null)
    {
        string loggedinuser = Membership.GetUser().ToString();
        yourdiv.InnerHtml = loggedinuser;
    }

    for the above to work you need

    using System.Web.Security; // this enables Membership

    I'm assuming that you want to place the username somewhere and you have a way of doing it like with a div or a span or a label.  Is this correct?

    -Larry

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, January 4, 2009 8:35 PM
  • User1806461582 posted

    Hi Larry,

    1. I am using c#.
    2. Where would I place the above code (in master)
    3. I am open to suggession as which to use (div,span or label)?

    Please suggest.

    Thanks a lot

    Monday, January 5, 2009 6:20 PM
  • User-1760427068 posted

    Because the answer is "You can put it anywhere" (and that sounds vague and evasive) I'm going to try a different strategy.  I built a web site that has four pages (a masterpage and three more pages: Default.aspx, Login.aspx, AnotherPage.aspx).  I'm showing all four pages below, using a single line of asterisks between aspx and aspx.cs  and using four lines of asterisks between pages.  A post after this will discuss what to look for:

    • ***MasterPage.master
    • **************************************
    • **************************************
    • ************************************** 
      <%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
      
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      
      <html xmlns="http://www.w3.org/1999/xhtml">
      <head runat="server">
          <title></title>
          
          <style type="text/css" media="all">
          #topline {background-color: #DDF;}
          #maincontent {background-color: #FF8;}
          #bottomline {background-color: #F99;}
          </style>
          
          <asp:ContentPlaceHolder id="head" runat="server">
          </asp:ContentPlaceHolder>
      </head>
      <body>
          <form id="form1" runat="server">
          
              <div id="topline">
      
              <span id="spanid" runat="server" />
              <div id="divid" runat="server" />
              <asp:Label ID="Labelid" runat="server" Text="You need to login..."></asp:Label>
              
              </div>
              
              <br /><br />
              
              <div id="maincontent">
              <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
              
              </asp:ContentPlaceHolder>
              </div>
              
              <div id="bottomline">
              <p>I went to the ASP.NET Web Site Administration Tool and went to Security and for Select Authentication type I 
              changed it to 'From the internet'.</p>
              <p>That was the only change I made at the Web Site Administration Tool.</p>
              </div>
      
          </form>
      </body>
      </html>

    *****************************************

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.Security; // this enables Membership
    
    
    public partial class MasterPage : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            MembershipUser membershipUser = Membership.GetUser();
            if (membershipUser != null)
            {
                string loggedinuser = Membership.GetUser().ToString();
                divid.InnerHtml = "divid username: " + loggedinuser;
                spanid.InnerHtml = "spanid username: " + loggedinuser;
                Labelid.Text = "Labelid username: " + loggedinuser;
            }
            else
            {
                Labelid.Text = "I went through protected void Page_Load and membershipUser was null, sorry!";
            }
        }
    }
     
    • ***Default.aspx
    • **************************************
    • **************************************
    • ************************************** 
      <%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
      
      <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
      </asp:Content>
      <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
      <p>This is the Default.aspx page.</p>
      <p>Now go to <a href="AnotherPage.aspx">AnotherPage.aspx</a></p>
      </asp:Content

    *********************************

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
    
        }
    }
     
    • ***Login.aspx
    • **************************************
    • **************************************
    • ************************************** 
      <%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Login" %>
      
      <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
      </asp:Content>
      <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
      
          <table><tr>
      
          <td>
      
          <asp:Login ID="Login1" runat="server">
          </asp:Login>
          
              <asp:LoginStatus ID="LoginStatus1" runat="server" />
          
          </td>
          <td width="50"></td>
          <td>
          
          <asp:CreateUserWizard ID="CreateUserWizard1" runat="server">
              <WizardSteps>
                  <asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server">
                  </asp:CreateUserWizardStep>
                  <asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server">
                  </asp:CompleteWizardStep>
              </WizardSteps>
          </asp:CreateUserWizard>
          
          </td>
          
          </tr><table>
          
          
              <p>Now go to <a href="AnotherPage.aspx">AnotherPage.aspx</a>.</p>
      
      </asp:Content>

    *****************************************

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
    
        }
    }
     
    • ***AnotherPage.aspx
    • **************************************
    • **************************************
    • ************************************** 
      <%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="AnotherPage.aspx.cs" Inherits="AnotherPage" %>
      
      <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
      </asp:Content>
      <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
      
      <p>This is another page.</p>
      <p>Go back to the <a href="Login.aspx">Login page</a> and log out.</p>
      
      </asp:Content>

    *********************************

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    public partial class AnotherPage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
    
        }
    }
     
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 5, 2009 8:32 PM
  • User-1760427068 posted

    Admittedly, it's going to be tedious to build the four pages above to prove the example.  I estimate about 5 minutes of work to build the example.  However, after the example is created you will have a model system to which you can make alterations to see what happens as a result of the changes.

    It doesn't matter whether you use div or span or textbox so I thought, why not put in all three and prove it.

    Next, we needed several pages.  You said masterpage so I wanted this example to show that if you build the feature on the masterpage you'll never have to write anything about it on any other page.  I could have just said that, and it probably would have made sense, but it will be more real when you see it.

    We built the Default.aspx page next because if you didn't have it at some point the program would look for it and if it wasn't there you would get a white screen, and that causes panic.

    We then built the Login.aspx page (which also has a register tool) so that you can login and see how the line at the top changes.  The Login.aspx page also has a tool for logout.  This is helpful because you can login and logout and verify that the upper line is mirroring the changes without fail.

    I mentioned on the masterpage what I did with the Web Site Administration Tool (look for the hammer and world icon under Solution explorer--it's the icon furthest to the right--at least this is true for Visual Web Developer.  This note was also built there to fill space in the part that is the bottomline div on the masterpage.

    Note that we built three different div areas with three different colors.    This takes us back to the original question "where should I put it?  or in this case, where should I put them?"

    Once you are satisfied that the example works (with "them" in the blue area) move "them" to another place on the masterpage and then test the different pages again.  I think after you have moved it to three different places you will be convinced that it doesn't matter--and I think as an indirect benefit you will have a higher confidence for what you can do with a masterpage which will benefit you when you work with future designs.

    Given the amount of time that I put into building this, and the amount of time that you put into making it, I would recommend that you tell me after you have finished this, and maybe we use this example to do a few more things (it is important to mark the post as resolved and issue points both to show good faith and also because other persons seeing a "Not Resolved" and coming here and finding it resolved (after reading for five minutes) will feel something bad and I don't want any of them to be unhappy about wasting the five minutes.

    for my notes- this project is "TestLogin"

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 5, 2009 8:47 PM
  • User1806461582 posted

    wow. great answers in detail. I will try your sample tonight and give you the feedback. and will mark this post completed.

    Thanks a lotttttt.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 6, 2009 3:19 PM
  • User555306248 posted

    You can use this code

    MembershipUser membershipUser = Membership.GetUser();
    if (membershipUser != null)
    {
        string loggedinuser = Membership.GetUser().ToString();
        yourdiv.InnerHtml = loggedinuser;
    }

    also there is another option to get user name

    HttpContext.Current.User.Identity

    http://msdn.microsoft.com/en-us/library/system.web.httpcontext.user.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 6, 2009 10:30 PM
  • User1806461582 posted

    Great job guys. It worked like charm. I am going to elaborate which order they need to take place.

    step1: Add a Label right above <div login> area in masterpage.master page. Lets call that lblShowUser
    step2: on load for masterpage.master.cs page put this code

         MembershipUser
    membershipUser = Membership.GetUser();
                if (membershipUser != null)
                   {
                     
    string loggedinuser = Membership.GetUser().ToString();
                      lblShowUser.Text =
    "Welcome " + loggedinuser;
                   }
                  
    else
                  
    {
                      lblShowUser.Text =
    "";
                   }

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 6, 2009 11:33 PM
  • User-1760427068 posted

    OK, I'm going to go ahead and build a "second generation example."   What we did here was an experiment and it appears the "gamble" paid off, so I'd like to roll the dice again.  Would you like me to also include the code mentioned by the second poster, Chetan?  The reason I bring it up, I'm planning to anyway, simply so we have the value of the experience of trying something new and exploring it--but also, if you used it and you found something you liked better about it then we could use that specifically.

    I don't want to promise it but I'm thinking the next generation could have a folder called Admin which has stuff that is accessible only if a logged in person happens to have been approved as an Admin role person.  Maybe also have a customer Role too.  Please note (if you haven't come across this already)--when a person registers they immediately have a status change--but maybe that person who registered is your business competitor so you want to create a role for Customers so that you have to approve them before they actually are granted access (in this case to a folder called Customers).

    I haven't done it for a while but my memory says we can do something in the web.config file to specify folder access and then maybe once a day you go into the page (can't remember the name but it is the hammer and world icon furthest to the right under Solution Explorer) and you look at people who are registered and you give them approvals there (I'm pretty sure this can also be done programmatically.)  Are you working on a "local machine" like a laptop or a desktop, or are you working on server (like a server at work or a commercial web site provider)?

    OK, this new example might have even more files to copy but, hey, we're ready to gamble that it will be worth it, right? (and the gamble is that another person coming here for the original question is going to want to go down this same path).

    Also, when you reply post, keep telling me what you would like.  It helps to have several things because I'll start with what I know right away and then I'll work on what I need to learn while doing the rest (I'll also have a long page that has all the files and I'll update it periodically until all are finished).

    -Larry

    Wednesday, January 7, 2009 9:24 AM
  • User555306248 posted

    Nice one

    Thursday, January 15, 2009 10:28 PM
  • User-635250172 posted

    Bulding off this code, I put this code in my master page:

      

    1    <div id="userLoggedIn" runat="server">
    2    </div>
    

     

    Then in my Page_Load method, I put this code: 

    1            // if user is logged in, set the innerhtml of the userLoggedIn div to show the user name
    2            // else, set the text telling the user how to log in.
    3            if (System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
    4            {
    5                string userName = "<p>Hello, " + System.Web.HttpContext.Current.User.Identity.Name +
    6                    "! Not you? <a href=\"Default.aspx\">Click here to log in.</a><p>";
    7                userLoggedIn.InnerHtml = userName;
    8            }
    9            else
    10           { 
    11               string userName = "<p><a href=\"week2.aspx\">Click here to log in.</a><p>";
    12               userLoggedIn.InnerHtml = userName; 
    13           }
    

     

    Now the user name displays when the user is logged in.

    Thank you for answering this guy's questions. :)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, February 22, 2009 2:59 AM
  • User555306248 posted

    Thats nice

    Monday, February 23, 2009 10:22 PM
  • User-293064608 posted

     Hello-

    I saw this post which is pretty much what I am looking for except that I'm not using the Membership.  I am validating users against oracle table.  Is there a way to display username as they login to the page when connecting to oracle table???

     

     

    Tuesday, August 25, 2009 5:10 PM
  • User1806461582 posted

     quickest way to do it use session state to store name. (of course, u should b using stored procedure to do this).

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 25, 2009 7:32 PM
  • User555306248 posted

     Afetr authenticating the user, store that user name in Session. Add label t Master Page then set the text to it

    Label.Text = Session["UserName"].ToString();

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 25, 2009 11:24 PM
  • User-293064608 posted

    How can I store the username in Session?  I know you add the Label.Text = Session["UserName"].ToString(); in the default page.  Can you tell me step by step in storing username? I am using Oracle database.

    Somehow I get his error: Object reference not set to an instance of an object

    Wednesday, August 26, 2009 11:42 AM
  • User555306248 posted

     How you are passing the username and password to the oracle table.

    Read it from textbox when you click the button from lagin form, if the authentication successful, store that user name in session

    Wednesday, August 26, 2009 10:57 PM
  • User-293064608 posted

     Basically this is how I am passing the username and password to oracle table.

    void LoginUser(object s, EventArgs e)
        {
            bool blnAuthenticate = Authenticate(username.Text, password.Text);
            if (blnAuthenticate)
            {
                FormsAuthentication.RedirectFromLoginPage(username.Text, true);
            }
            else
            {
                lblError.Text = "Your login was invalid. Please try again.";
            }
        }
       
        bool Authenticate(string strusername, string strPassword)
        {   //declaring objects
            OracleConnection objConn = new OracleConnection(ConfigurationManager.AppSettings["DSN"]);
            OracleCommand objComd;
            OracleDataReader objDR;
            bool userFound;
           
            objComd = new OracleCommand("SELECT * FROM REGISTER " + "WHERE USER_NAME='"
                + strusername + "' AND PASSWORD='" + strPassword + "'", objConn);
           
            objConn.Open();
            objDR = objComd.ExecuteReader();
            userFound = objDR.Read();
            objDR.Close();
           
            return userFound;
        }

    From here what do I need to add in order to display username when they logged in (example: "Welcome Cadeey")

    I appreciate your help.....Smile.

    Thursday, August 27, 2009 3:54 PM
  • User555306248 posted

    When the code executes

    FormsAuthentication.RedirectFromLoginPage(username.Text, true);

    store "username.Text" in Session

    Session["UserName"] = username.Text;

    When it redirects (logged in) palce this value to lable

    userNameLabel.text = "Welcome " + Session["UserName"].ToString();


     

    Sunday, August 30, 2009 10:52 PM
  • User-293064608 posted

    Thanks Chetan.  That works.

    Monday, August 31, 2009 9:19 AM
  • User555306248 posted

     Glad it helps you

    Monday, August 31, 2009 10:54 PM
  • User-293064608 posted

    Question about username being in case insensitive.

    I have a database table where registered users' information is stored in.  When the user registers their username is stored in as in uppercase in the database and when the user tries to login they can only use uppercase username.  I want to make the username in case insensitive.  Any help will do.

    Tuesday, September 1, 2009 9:36 AM
  • User-293064608 posted

    Another quick question, when the user logins in my username is case sensitive (uppercase).  How can I make the username in case insensitive?  The database is storing username in uppercase letters.

    Tuesday, September 1, 2009 10:36 AM
  • User555306248 posted

     Why you are stroing it in UpperCase, is there any reason.

    You can pass username to databse in uppercase, while authenticating, pass in uppercase only

    bool Authenticate(string username, strin password)

    {

       string uname = username.ToUpper();

    }

    Tuesday, September 1, 2009 11:01 PM
  • User-293064608 posted

    Actually it is not storing uppercase only.  It all depends on how the user enters it when they are registering.  However, regardless of their cases (Upper or Lower) I would like to make the username case insensitive.

    For example: If user types in Cadeey or CADEEY it shouldn't matter when they are login in.

    Here's my code behind for the login page:

    void LoginUser(object s, EventArgs e)
        {
            bool blnAuthenticate = Authenticate(username.Text, password.Text);
            if (blnAuthenticate)
            {
                FormsAuthentication.RedirectFromLoginPage(username.Text, true);
                Session["UserName"] = username.Text;
            }
            else
            {
                lblError.Text = "Your login was invalid. Please try again.";
            }
        }
       
        bool Authenticate(string strusername, string strPassword)
        {   //declaring objects
            OracleConnection objConn = new OracleConnection(ConfigurationManager.AppSettings["DSN"]);
            OracleCommand objComd;
            OracleDataReader objDR;
            bool userFound;
           
            objComd = new OracleCommand("SELECT * FROM REGISTER " + "WHERE USER_NAME='"
                + strusername + "' AND PASSWORD='" + strPassword + "'", objConn);
           
            objConn.Open();
            objDR = objComd.ExecuteReader();
            userFound = objDR.Read();
            objDR.Close();
           
            return userFound;
        }

    Wednesday, September 2, 2009 11:06 AM
  • User-293064608 posted

     I did not get the solution to my last problem.  Any ideas?

    Tuesday, September 8, 2009 3:54 PM
  • User555306248 posted

     You are saying that "I would like to make the username case insensitive" also

    "For example: If user types in Cadeey or CADEEY it shouldn't matter when they are login in."

    Can you please confirm on that which one you want

     

    Tuesday, September 8, 2009 10:55 PM
  • User-293064608 posted

     That is exactly what I am saying.

    If user types in Cadeey or CADEEY it shouldn't matter when they are login in."

    Wednesday, September 9, 2009 10:09 AM
  • User555306248 posted

     While authenticating, you can always pass username in lower case. If user provide CADEEY hen you can provide to the DB as "caseey" using ToLower()

    Wednesday, September 9, 2009 10:58 PM
  • User-293064608 posted

    Can you please show me how to pass lowercase username while authenticating using the code below?  I tried putting tolower() after .text and it's not working.

    void LoginUser(object s, EventArgs e)
        {
            bool blnAuthenticate = Authenticate(username.Text, password.Text);
            if (blnAuthenticate)
            {
                FormsAuthentication.RedirectFromLoginPage(username.Text, true);
                Session["UserName"] = username.Text;
            }
            else
            {
                lblError.Text = "Your login was invalid. Please try again.";
            }
        }
       
        bool Authenticate(string strusername, string strPassword)
        {   //declaring objects
            OracleConnection objConn = new OracleConnection(ConfigurationManager.AppSettings["DSN"]);
            OracleCommand objComd;
            OracleDataReader objDR;
            bool userFound;
           
            objComd = new OracleCommand("SELECT * FROM REGISTER " + "WHERE USER_NAME='"
                + strusername + "' AND PASSWORD='" + strPassword + "'", objConn);
           
            objConn.Open();
            objDR = objComd.ExecuteReader();
            userFound = objDR.Read();
            objDR.Close();
           
            return userFound;
        }

    Thursday, September 10, 2009 3:36 PM
  • User555306248 posted

     Try this

    bool blnAuthenticate = Authenticate(username.Text.Tostring().ToLower(), password.Text);

    Thursday, September 10, 2009 11:00 PM
  • User-293064608 posted

    Your solution works however if I have username first character as Upper and the rest Lower how would I do that?

    For example: Cadeey

    Friday, September 11, 2009 4:38 PM
  • User555306248 posted

    It will also work in that case

    Sunday, September 13, 2009 11:15 PM
  • User-293064608 posted

     hi chetan, did you receive my last message regarding the calendar display?

    Thursday, September 17, 2009 4:22 PM
  • User555306248 posted

     Yes, for that requirement I will suggest take a look at

    http://www.telerik.com/products/aspnet-ajax/calendar.aspx

    Thursday, September 17, 2009 10:44 PM
  • User555306248 posted

     Have you looked into the url I provided, does it matches to your requirement

    Monday, September 21, 2009 11:29 PM
  • User-293064608 posted

     The URL you send me give me partial of what I was looking for.  I am able to display project due dates on the calendar but I am not able to do that based on loging username. 

    I need couple of things to happen:

    1) Employee logs in then views his/her own projects

    This is my code behind for the calendar so far.

    protected void Page_Load(object sender, EventArgs e)
        {

            Label1.Text = "Welcome, " + Session["UserName"].ToString();

           if (!Page.IsPostBack)
            {
                //calls the bind method
                BindData();
            }
        }

        protected void BindData()
        {
            OracleConnection myConnection = new OracleConnection(ConfigurationManager.AppSettings["DSN"]);
            OracleCommand myCommand = new OracleCommand("SELECT DISTINCT a.PROJECT_DUE FROM NEW_PROJECTS a, REGISTER b WHERE b.USER_NAME = '" + Session["UserName"]+ "'", myConnection);
            myCommand.CommandType = CommandType.Text;

            myConnection.Open();
            OracleDataReader dr = myCommand.ExecuteReader();

            while(dr.Read()==true)
            {
                //assign the calendar control dates already contained in the database
                Calendar1.SelectedDates.Add((DateTime) dr.GetOracleDateTime(0));
            }
            dr.Close();
            myConnection.Close();
        }

     

    Tuesday, September 22, 2009 5:23 PM
  • User555306248 posted

     I am able to display project due dates on the calendar but I am not able to do that based on loging username

    can you explain ? is query retrun perfect record that you want

    Tuesday, September 22, 2009 11:06 PM
  • User-293064608 posted

    For example, if i login as Cadeey it should only give me all active projects assigned to Cadeey.  At the moment it is displaying all projects assigned to everyone when Cadeey logins in.  Also, I would like for a teacher to view all assigned employees projects.  Below are the two tables I am using to accomplish this task.

    Table 1 = NEW_ASSIGNMENT:

    PROJECT

    DUE DATE

    REQUESTER

    DESCRIPTION

    CATEGORY

    STATUS

    ASSIGNED TO

    TEST

    9/23/09

    Teacher

    TEST1

    Biology

    Active

    Cadeey

    Table 2 = REGISTRATION:

    FIRST NAME

    LAST NAME

    EMAIL

    USER_NAME

    PASSWORD

    CONFIRM_PASSWORD

    STUDENT_ID

    REPORTS_TO

    CADEEY

    CAD

    CADEEY@HOTMAIL.COM

    CADEEY

    TEST123

    Active

    12345

    DR.JOE

     

    Wednesday, September 23, 2009 9:28 AM
  • User555306248 posted

     I think this can be done using Role assignment, for whom to display all project (loke Project Manager) and for Employee only displaytheir project

    Wednesday, September 23, 2009 11:06 PM
  • User-293064608 posted

    I am not using ASP.net membership.  I have created my own tables in Oracle database.  Based on my code-behind where do I go from here.

    protected void Page_Load(object sender, EventArgs e)
        {

            Label1.Text = "Welcome, " + Session["UserName"].ToString();

           if (!Page.IsPostBack)
            {
                //calls the bind method
                BindData();
            }
        }

        protected void BindData()
        {
            OracleConnection myConnection = new OracleConnection(ConfigurationManager.AppSettings["DSN"]);
            OracleCommand myCommand = new OracleCommand("SELECT DISTINCT a.PROJECT_DUE FROM NEW_PROJECTS a, REGISTER b WHERE b.USER_NAME = '" + Session["UserName"]+ "'", myConnection);
            myCommand.CommandType = CommandType.Text;

            myConnection.Open();
            OracleDataReader dr = myCommand.ExecuteReader();

            while(dr.Read()==true)
            {
                //assign the calendar control dates already contained in the database
                Calendar1.SelectedDates.Add((DateTime) dr.GetOracleDateTime(0));
            }
            dr.Close();
            myConnection.Close();
        }

     

    Thursday, September 24, 2009 9:26 AM
  • User555306248 posted

     Then how can you identify that logged in user is Project Manager or Employee. I think you can use ASP.net membership with Oracle Databse

    http://forums.asp.net/t/1032597.aspx

    http://weblogs.asp.net/rudysetyo/archive/2008/11/20/asp-net-membership-and-role-provider-using-oracle-database-part-1.aspx

    Thursday, September 24, 2009 11:10 PM
  • User-293064608 posted

     I am using Oracle table, I am not familiar with role managers or asp.net membership.  The URLs you gave me aren't available anymore.  Please post step by step way of creating an asp.net membership, role managers while i'm using my oracle database table. 

    Thanks

    Monday, September 28, 2009 11:45 AM
  • User555306248 posted

     This URl is opened here. Well will suggest another way.

    Monday, September 28, 2009 11:30 PM
  • User-293064608 posted

    I don't really think I need to use role managers in my case.  What I've been trying to test was to select username from the table and compare with the session username.  How do I do that???

    For example: I register an account with a username: Cadeey, this is then stored in my table then a project is assigned to Cadeey with a due date this is also stored in another table.  Scenario - Cadeey logs in then on calendar render selects Username and compares with session name if exists it pulls the due date.  That's all I'm trying to do for now, let me test for employees then I'll test for managers.  PLEASE HELPPPPPPPP!

    My code behind:

    protected void Page_Load(object sender, EventArgs e)
        {

            Label1.Text = "Welcome, " + Session["UserName"].ToString();

           if (!Page.IsPostBack)
            {
                //calls the bind method
                BindData();
            }
        }

        protected void BindData()
        {
            OracleConnection myConnection = new OracleConnection(ConfigurationManager.AppSettings["DSN"]);
            OracleCommand myCommand = new OracleCommand("SELECT DISTINCT a.PROJECT_DUE FROM NEW_PROJECTS a, REGISTER b WHERE b.USER_NAME = '" + Session["UserName"]+ "'", myConnection);
            myCommand.CommandType = CommandType.Text;

            myConnection.Open();
            OracleDataReader dr = myCommand.ExecuteReader();

            while(dr.Read()==true)
            {
                //assign the calendar control dates already contained in the database
                Calendar1.SelectedDates.Add((DateTime) dr.GetOracleDateTime(0));
            }
            dr.Close();
            myConnection.Close();
        }

    Tuesday, September 29, 2009 10:26 AM
  • User555306248 posted

     I will think another way and post it

    Wednesday, September 30, 2009 1:18 AM
  • User-293064608 posted

    Ok..........I'll wait....Smile.

    Wednesday, September 30, 2009 9:23 AM
  • User555306248 posted

     If you  don't really think you need to use role managers in your case,then how you would you recognize which project to show whom

    Wednesday, September 30, 2009 11:09 PM
  • User-293064608 posted

    I have two tables: Registration and New_Projects

    Registration table has the following fields: ID, FIRST NAME, LAST NAME, EMAIL, REPORTS TO MANAGER, USERNAME, PASSWORD, CONFIRM PASSWORD

    New_Projects has the following fields: PROJECT NAME, DUE DATE, REQUESTED MANAGER, DESCRIPTION, CATEGORY, PROJECT STATUS, ASSIGNED TO MANAGER, PRIORITY LEVEL (LOW, MEDIUM, HIGH)

    When employees registers with username it stores in registration table. For new projects table, the employees are assigned to projects with due dates with their requested manager.

    What I tried to do:
    I tried to compare the username that's stored in registration table with the session username which are identical and if its the same then I select the project due date for all active projects.  And for managers which I haven't tried yet, I'd like to say if username is manager then select all employees reports to that manager and their project due dates (all active ones).

    protected void Page_Load(object sender, EventArgs e)
        {

            Label1.Text = "Welcome, " + Session["UserName"].ToString();

           if (!Page.IsPostBack)
            {
                //calls the bind method
                BindData();
            }
        }

        protected void BindData()
        {
            OracleConnection myConnection = new OracleConnection(ConfigurationManager.AppSettings["DSN"]);
            OracleCommand myCommand = new OracleCommand("SELECT DISTINCT a.PROJECT_DUE FROM NEW_PROJECTS a, REGISTER b WHERE b.USER_NAME = '" + Session["UserName"].ToString()+ "' AND a.PROJ_STATUS = 'Active'", myConnection);
            myCommand.CommandType = CommandType.Text;

            myConnection.Open();
            OracleDataReader dr = myCommand.ExecuteReader();

            while(dr.Read()==true)
            {
                //assign the calendar control dates already contained in the database
                Calendar1.SelectedDates.Add((DateTime) dr.GetOracleDateTime(0));
            }
            dr.Close();
            myConnection.Close();
        }

    This compiles without an error but not getting the result I want.

    Thursday, October 1, 2009 10:31 AM
  • User-293064608 posted

     Hi Chedan-

    Please disregard the previous message.  I've resolved the issue.

    Thanks newayz.

    Thursday, October 1, 2009 4:51 PM
  • User555306248 posted

     Thats nice

    Sunday, October 4, 2009 11:11 PM
  • User555306248 posted

    Can ypu please tell how you resolved it 

    Wednesday, October 7, 2009 11:05 PM
  • User-293064608 posted

    Hi Chetan-

    Basically, I've used SQL triggers to compare usernames.  It's similar to using asp.net roles.

    Now I have another question.  In my calendar, I want to do the following things:

    1) Select a due date then redirect user to edit form while it populates data from new_project form.
    2) Allow user to update fields then add an audit field which displays time, day it got updated and user who updated it.

    Wednesday, October 14, 2009 4:02 PM
  • User-293064608 posted

    Here's my code:

    public partial class _Default : System.Web.UI.Page

    {

            protected void Page_Load(object sender, EventArgs e)

        {

     

            Label1.Text = "Welcome, " + Session["UserName"].ToString();

            BindData();

        }

     

        protected void BindData()

        {

            if (!IsPostBack)

            {

                if (Session["UserName"].ToString() != null)

                {

                    string SessionName = Session["UserName"].ToString();

                    //Response.Write(Session["UserName"].ToString());

     

                    // Declare the query string.

                    OracleConnection myConnection = new OracleConnection(ConfigurationManager.AppSettings["DSN"]);

                    OracleCommand myCommand = new OracleCommand("SELECT a.PROJECT_DUE FROM NEW_PROJECTS a WHERE upper(a.REPORTS_TO_ID) = '" + Session["UserName"].ToString() + "'or lower(a.REPORTS_TO_ID) = '" + Session["UserName"].ToString() + "' or upper(a.ASSIGNED_TO_ID) = '" + Session["UserName"].ToString() + "'or lower(a.ASSIGNED_TO_ID) = '" + Session["UserName"].ToString()+ "'and a.proj_status = 'Active'", myConnection);

                    myCommand.CommandType = CommandType.Text;

     

                    myConnection.Open();

                    OracleDataReader dr = myCommand.ExecuteReader();

     

                    while (dr.Read() == true)

                    {

                        //assign the calendar control dates already contained in the database

                        Calendar1.SelectedDates.Add((DateTime)dr.GetOracleDateTime(0));

                    }

                    dr.Close();

                    myConnection.Close();

                }

            }

        }

     

       

        protected void LoginStatus1_LoggingOut(object sender, LoginCancelEventArgs e)

        {

            FormsAuthentication.SignOut();

            Response.Redirect("Login.aspx");

        }

     

     

     

    protected void Calendar1_SelectionChanged(object sender, EventArgs e)

    {

          I NEED CODE THAT WILL ALLOW ME TO SELECT THE DUE DATES AND POPULATE DATA FROM NEW_PROJECT PAGE TO EDIT PAGE

    }

     

    Thursday, October 15, 2009 4:29 PM
  • User555306248 posted

     You can query to DB and compaire the project dates so that you can get due date and populate data

    Thursday, October 15, 2009 11:19 PM
  • User-293064608 posted

    I need start-up code to begin since I am learning. 

    Friday, October 16, 2009 10:51 AM
  • User-319574463 posted

    >I need start-up code to begin since I am learning.
    What language are you using?

    Friday, October 16, 2009 12:21 PM
  • User-293064608 posted

    Asp.net....C# 

    Sunday, October 18, 2009 11:59 AM
  • User-319574463 posted

    If the user is on the same local network, then use

        /// <summary>
        /// Gets logged-in user name
        /// </summary>
        /// <returns>logged-in user name</returns>
        public static string GetUserName
        {
          get { return Environment.UserName; }
        }

    Sunday, October 18, 2009 2:30 PM
  • User-293064608 posted

    This wont work in my case, because I am storing Username in a session state (From DB).

    Here's my code:

    public partial class _Default : System.Web.UI.Page

    {

            protected void Page_Load(object sender, EventArgs e)

        {

     

            Label1.Text = "Welcome, " + Session["UserName"].ToString();

            BindData();

        }

     

        protected void BindData()

        {

            if (!IsPostBack)

            {

                if (Session["UserName"].ToString() != null)

                {

                    string SessionName = Session["UserName"].ToString();

                    //Response.Write(Session["UserName"].ToString());

     

                    // Declare the query string.

                    OracleConnection myConnection = new OracleConnection(ConfigurationManager.AppSettings["DSN"]);

                    OracleCommand myCommand = new OracleCommand("SELECT a.PROJECT_DUE FROM NEW_PROJECTS a WHERE upper(a.REPORTS_TO_ID) = '" + Session["UserName"].ToString() + "'or lower(a.REPORTS_TO_ID) = '" + Session["UserName"].ToString() + "' or upper(a.ASSIGNED_TO_ID) = '" + Session["UserName"].ToString() + "'or lower(a.ASSIGNED_TO_ID) = '" + Session["UserName"].ToString()+ "'and a.proj_status = 'Active'", myConnection);

                    myCommand.CommandType = CommandType.Text;

     

                    myConnection.Open();

                    OracleDataReader dr = myCommand.ExecuteReader();

     

                    while (dr.Read() == true)

                    {

                        //assign the calendar control dates already contained in the database

                        Calendar1.SelectedDates.Add((DateTime)dr.GetOracleDateTime(0));

                    }

                    dr.Close();

                    myConnection.Close();

                }

            }

        }

     

       

        protected void LoginStatus1_LoggingOut(object sender, LoginCancelEventArgs e)

        {

            FormsAuthentication.SignOut();

            Response.Redirect("Login.aspx");

        }

     

     

     

    protected void Calendar1_SelectionChanged(object sender, EventArgs e)

    {

          I NEED CODE THAT WILL ALLOW ME TO SELECT THE DUE DATES AND POPULATE DATA FROM NEW_PROJECT PAGE TO EDIT PAGE

    }

    Monday, October 19, 2009 10:57 AM
  • User555306248 posted

    I guess you have already resolved the code for getting the user name 

    Monday, October 19, 2009 11:27 PM
  • User-293064608 posted

    I did figured out getting the username, I need help with the calendar selection dates and redirecting to a new page.

    Tuesday, October 20, 2009 3:54 PM
  • User555306248 posted

    There is Selectionchnaged event for Calendar, you can get the selected date from it 

    Tuesday, October 20, 2009 11:15 PM
  • User-293064608 posted

    Chetan-

    That's the part I need help with....The SelectionChanged Event.  I want to select only the due dates in the calendar and redirect to another page by populating data from another page.  Please see my code below and help me in this matter ASAP.

    Here's my code:

    public partial class _Default : System.Web.UI.Page

    {

            protected void Page_Load(object sender, EventArgs e)

        {

     

            Label1.Text = "Welcome, " + Session["UserName"].ToString();

            BindData();

        }

     

        protected void BindData()

        {

            if (!IsPostBack)

            {

                if (Session["UserName"].ToString() != null)

                {

                    string SessionName = Session["UserName"].ToString();

                    //Response.Write(Session["UserName"].ToString());

     

                    // Declare the query string.

                    OracleConnection myConnection = new OracleConnection(ConfigurationManager.AppSettings["DSN"]);

                    OracleCommand myCommand = new OracleCommand("SELECT a.PROJECT_DUE FROM NEW_PROJECTS a WHERE upper(a.REPORTS_TO_ID) = '" + Session["UserName"].ToString() + "'or lower(a.REPORTS_TO_ID) = '" + Session["UserName"].ToString() + "' or upper(a.ASSIGNED_TO_ID) = '" + Session["UserName"].ToString() + "'or lower(a.ASSIGNED_TO_ID) = '" + Session["UserName"].ToString()+ "'and a.proj_status = 'Active'", myConnection);

                    myCommand.CommandType = CommandType.Text;

     

                    myConnection.Open();

                    OracleDataReader dr = myCommand.ExecuteReader();

     

                    while (dr.Read() == true)

                    {

                        //assign the calendar control dates already contained in the database

                        Calendar1.SelectedDates.Add((DateTime)dr.GetOracleDateTime(0));

                    }

                    dr.Close();

                    myConnection.Close();

                }

            }

        }

     

       

        protected void LoginStatus1_LoggingOut(object sender, LoginCancelEventArgs e)

        {

            FormsAuthentication.SignOut();

            Response.Redirect("Login.aspx");

        }

     

     

     

    protected void Calendar1_SelectionChanged(object sender, EventArgs e)

    {

          I NEED CODE THAT WILL ALLOW ME TO SELECT THE DUE DATES AND POPULATE DATA FROM NEW_PROJECT PAGE TO EDIT PAGE

    }

    Wednesday, October 21, 2009 9:37 AM
  • User-293064608 posted

    Hi Chetan-

    I found some code for my SelectionChanged event:

     Protected void Calendar1_SelectionChanged(object sender, EventArgs e)

    {
    Response.Redirect("edit_project.aspx?PROJECT_DUE=" + (System.DateTime)Calendar1.SelectedDate);

    System.DateTime d = default(System.DateTime);

    //grab project due date

    d = (System.DateTime)Request["PROJECT_DUE"];
    }

    However, I am getting this error message: Cannot convert type 'string' to 'System.DateTime'

    Am I missing something???


     



     

    Thursday, October 22, 2009 3:12 PM
  • User-293064608 posted

    Hi Chetan-

    I've put the pieces together on selecting days from calendar.  Now I am trying to load selected date data into a form.  For some reason, when I select a date from the calendar I am getting this date displayed '01/01/0001'.  Where is this coming from and what am I doing wrong or missing based on my code behind below?  PLEASE HELP!!!
     
    Calendar Render

    protected void Calender1_DayRender(object sener, DayRenderEventArgs e)
    {
    // Declare the query string.

    OracleConnection myConnection = new OracleConnection(ConfigurationManager.AppSettings["DSN"]);
    OracleCommand myCommand = new OracleCommand("SELECT a.PROJECT_DUE FROM NEW_PROJECTS a WHERE upper(a.REPORTS_TO_ID) = '" + Session["UserName"].ToString() + "'or lower(a.REPORTS_TO_ID) = '" + Session["UserName"].ToString() + "' or upper(a.ASSIGNED_TO_ID) = '" + Session["UserName"].ToString() + "'or lower(a.ASSIGNED_TO_ID) = '" + Session["UserName"].ToString() + "'and a.proj_status = 'Active'", myConnection);
    OracleDataReader dr;

    myConnection.Open();
    dr = myCommand.ExecuteReader();

    while (dr.Read())
    {
    //assign the calendar control dates already contained in the database
    Calendar1.SelectedDates.Add((DateTime)dr.GetOracleDateTime(0));
    }
    dr.Close();
    myConnection.Close();
    }
     
    Calendar Selection
     
    protected void Calendar1_SelectionChanged(object sender, EventArgs e)
    {
    foreach (DateTime SelectedDate in Calendar1.SelectedDates)
    {
    Response.Redirect(
    "edit_project.aspx?PROJECT_DUE=" + Calendar1.SelectedDate.ToString("dd-MMM-yy"));

    System.
    DateTime d = default(System.DateTime);
    //grab project due date
    d = DateTime.Parse(Request["PROJECT_DUE"]);
    // LoadData();
    }
    }
     
    Form Load
     
    protected void LoadData()
    {
    //load data
    OracleConnection objConn = new OracleConnection();
    //string User_Name = User_Name.Substring;
    //string Password = Password.Substring;
    string strora = "SELECT PROJECT_NAME,PROJECT_DUE, REQUESTED_MANAGER, PROJ_DESCRIPTION, PROJ_CATEGORY, PROJ_STATUS, ASSIGNED_TO, PRIORITY_LEVEL FROM NEW_PROJECTS WHERE PROJECT_DUE = '" + Calendar1.SelectedDate.ToString("dd-MMM-yy") + "'";
    objConn.ConnectionString =
    ConfigurationManager.AppSettings["DSN"];
    OracleCommand objcmd = new OracleCommand(strora, objConn);
    objcmd.CommandType =
    CommandType.Text;
    objConn.Open();
    OracleDataReader reader = objcmd.ExecuteReader();
    reader.Read();
    Response.Write(Calendar1.SelectedDate.ToLongDateString());
    for (int x = 0; x < reader.FieldCount; x++)
    {
    // Response.Write("Project_Name");
    //Response.Write(Project_Name.Text);
     switch (reader.GetName(x).ToString())
    {
    case "PROJECT_NAME":
    Project_Name.Text = reader.GetValue(x).ToString();
    break;
    case "PROJECT_DUE":
    Project_Due.Text = reader.GetValue(x).ToString();
    break;
    case "REQUESTED_MANAGER":
    Requested_Manager.Text = reader.GetValue(x).ToString();
    break;
    case "PROJ_DESCRIPTION":
    Proj_Description.Text = reader.GetValue(x).ToString();
    break;
    case "PROJ_CATEGORY":
    Proj_Category.Text = reader.GetValue(x).ToString();
    break;
    case "PROJ_STATUS":
    Proj_Status.Text = reader.GetValue(x).ToString();
    break;
    case "ASSIGNED_TO":
    Assigned_To.Text = reader.GetValue(x).ToString();
    break;
    case "PRIORITY_LEVEL":
    Priority_Level.Text = reader.GetValue(x).ToString();
    break;
    }
    }

    objConn.Close();
    }

    Thursday, October 29, 2009 5:28 PM
  • User555306248 posted

     I think the date '01/01/0001' is displayed is by default, mean it is not bimding the control itself just debug the code lets see whether from DB date field is populating or not

    Monday, November 2, 2009 10:07 PM
  • User-293064608 posted

    My date is not binding with database.  Based on my code, how can I pass my due date so that it binds.  Please look through my code and let me know where I am missing. Basically, I want to be able to select a due date and load that due date's data ONLY into an edit form.

    Calendar Render Function

    protected
    void Calender1_DayRender(object source, DayRenderEventArgs e)
    {
    // Declare the query string.
    OracleConnection myConnection = new OracleConnection(ConfigurationManager.AppSettings["DSN"]);
    OracleCommand myCommand = new OracleCommand("SELECT to_date(a.PROJECT_DUE,'MM-dd-yyyy') FROM NEW_PROJECTS a WHERE upper(a.REPORTS_TO_UTSWID) = '" + Session["UserName"].ToString() + "'or lower(a.REPORTS_TO_ID) = '" + Session["UserName"].ToString() + "' or upper(a.ASSIGNED_TO_ID) = '" + Session["UserName"].ToString() + "'or lower(a.ASSIGNED_TO_ID) = '" + Session["UserName"].ToString() + "'and a.proj_status = 'Active'", myConnection);
    OracleDataReader dr;
     
    myConnection.Open();
    dr = myCommand.ExecuteReader();
     
    while (dr.Read())
    {
    //assign the calendar control dates already contained in the database
    Calendar1.SelectedDates.Add((DateTime)dr.GetOracleDateTime(0));
    }
    dr.Close();
    myConnection.Close();
    }
     
    Calendar SelectionChanged Function
     
    protected void Calendar1_SelectionChanged(object sender, EventArgs e)
    {

    Response.Redirect(
    "edit_project.aspx?PROJECT_DUE=" + Calendar1.SelectedDate.ToString("MM/dd/yyyy"));
    }
     
    Form Load Function
     
    protected void LoadData()
    {
    //load data
    OracleConnection objConn = new OracleConnection();
    // string User_Name = User_Name.Substring;
    //string Password = Password.Substring;
    // Response.Write(Calendar1.SelectedDate.ToString("MM/dd/yy"));
    string strora = "SELECT PROJECT_NAME, REQUESTED_MANAGER, PROJ_DESCRIPTION, PROJ_CATEGORY, PROJ_STATUS, ASSIGNED_TO, PRIORITY_LEVEL FROM NEW_PROJECTS WHERE PROJECT_DUE = 'to_char(" + Calendar1.SelectedDate.ToString("MM/DD/yyyy") + ")'";
    objConn.ConnectionString =
    ConfigurationManager.AppSettings["DSN"];
    OracleCommand objcmd = new OracleCommand(strora, objConn);
    objcmd.CommandType =
    CommandType.Text;
    objConn.Open();
    OracleDataReader reader = objcmd.ExecuteReader();
    reader.Read();
    //Response.Write(Calendar1.SelectedDate.ToString("MM/dd/yy"));
    for (int x = 0; x < reader.FieldCount; x++)
    {
    //Response.Write("Project_Name");
    // Response.Write(Project_Name.Text);
    switch (reader.GetName(x).ToString())
    {
    case "PROJECT_NAME":
    Project_Name.Text = reader.GetValue(x).ToString();
    break;
    case "PROJECT_DUE":
    Project_Due.Text = reader.GetValue(x).ToString();
    break;
    case "REQUESTED_MANAGER":
    Requested_Manager.SelectedValue = reader.GetValue(x).ToString();
    break;
    case "PROJ_DESCRIPTION":
    Proj_Description.Text = reader.GetValue(x).ToString();
    break;
    case "PROJ_CATEGORY":
    Proj_Category.SelectedValue = reader.GetValue(x).ToString();
    break;
    case "PROJ_STATUS":
    Proj_Status.SelectedValue = reader.GetValue(x).ToString();
    break;
    case "ASSIGNED_TO":
    Assigned_To.SelectedValue = reader.GetValue(x).ToString();
    break;
    case "PRIORITY_LEVEL":
    Priority_Level.SelectedValue = reader.GetValue(x).ToString();
    break;
    }
    }
     
    objConn.Close();
    }

    Tuesday, November 3, 2009 10:57 AM
  • User555306248 posted

    Will look into it 

    Tuesday, November 3, 2009 10:00 PM
  • User-293064608 posted

    Thanks Chetan. Please try to help me as I'm soo frustrated with this calendar thing.  When can I expect to see a solution??? 

    Tuesday, November 3, 2009 10:39 PM
  • User555306248 posted

    Use the TodaysDate property to determine today's date. You can also use this property to programmatically set the value for today's date on the Calendar control.

    http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.calendar.todaysdate.aspx 

    Wednesday, November 4, 2009 10:11 PM
  • User-293064608 posted

    Chetan, this is not helping me at all.

    Can you please post C# code in which I am able to select a datadriven date from calendar and once the date is selected data is populated into a form.  This sounds simple but difficult to do.  PLEASE HELP!

    Thursday, November 5, 2009 3:26 PM
  • User555306248 posted

    You mean to say that following line didn't set the dat what you want, correct

    //assign the calendar control dates already contained in the database
    Calendar1.SelectedDates.Add((DateTime)dr.GetOracleDateTime(0));
     

    Thursday, November 5, 2009 9:57 PM
  • User-293064608 posted

    yes 

    Thursday, November 5, 2009 10:59 PM
  • User-293064608 posted

    For some reason this code of line:  

    Calendar1.SelectedDates.Add((DateTime)dr.GetOracleDateTime(0)); is displaying my dates from the database, but when I select it is not giving me the right date, I am getting the minvalue set(01/01/0001).

    Thursday, November 5, 2009 11:06 PM
  • User555306248 posted

    If the values are binding properly first time and while selecting it is not gettimg that means the values are not eprsisited. Can you just confirm while selecting it is not binding again may be thats hw values not persisted 

    Sunday, November 8, 2009 10:04 PM
  • User-293064608 posted

    I need to know how I can pass my calendar selected date from my default page to my redirect page.  Here's my code behind:

    Default page – Calendar   

    public partial class _Default : System.Web.UI.Page

    {

       

     

        protected void Page_Load(object sender, EventArgs e)

        {

           

     

            Label1.Text = "Welcome, " + Session["UserName"].ToString();

     

            if (!IsPostBack)

            {

                if (Session["UserName"].ToString() != null)

                {

                    string SessionName = Session["UserName"].ToString();

                  

                }

     

     

            }

     

        }

     

         

        protected void LoginStatus1_LoggingOut(object sender, LoginCancelEventArgs e)

        {

            FormsAuthentication.SignOut();

            Response.Redirect("Login.aspx");

        }

     

        protected void Calender1_DayRender(object source, DayRenderEventArgs e)

        {

           

           

            // Declare the query string.

     

            OracleConnection myConnection = new OracleConnection(ConfigurationManager.AppSettings["DSN"]);

            OracleCommand myCommand = new OracleCommand("SELECT to_date(a.PROJECT_DUE,'MM/DD/YYYY') FROM NEW_PROJECTS a WHERE upper(a.REPORTS_TO_ID) = '" + Session["UserName"].ToString() + "'or lower(a.REPORTS_TO_ID) = '" + Session["UserName"].ToString() + "' or upper(a.ASSIGNED_ID) = '" + Session["UserName"].ToString() + "'or lower(a.ASSIGNED_TO_ID) = '" + Session["UserName"].ToString() + "'and a.proj_status = 'Active'", myConnection);

            OracleDataReader dr;

     

     

            myConnection.Open();

            dr = myCommand.ExecuteReader();

          

         

            while (dr.Read())

           {

               //assign the calendar control dates already contained in the database

              

            Calendar1.SelectedDates.Add((DateTime)dr.GetOracleDateTime(0));

            e.Cell.Text = "<a href='edit_project.aspx?PROJECT_DUE=" + e.Day.Date.ToString("MM/dd/yyyy") + "'>" + e.Day.DayNumberText + "</a>";

       

           }

          

           dr.Close();

           myConnection.Close();

          

       }

     

       protected void Calendar1_SelectionChanged(object sender, EventArgs e)

        {

     

            OracleConnection myConnection = new OracleConnection(ConfigurationManager.AppSettings["DSN"]);

            OracleCommand myCommand = new OracleCommand("SELECT PROJECT_NAME, PROJECT_DUE, REQUESTED_MANAGER, PROJ_DESCRIPTION, PROJ_CATEGORY, PROJ_STATUS, ASSIGNED_TO, PRIORITY_LEVEL FROM NEW_PROJECTS  WHERE PROJECT_DUE = '" + Calendar1.SelectedDate.ToString("MM/dd/yyyy") + "'", myConnection);

            OracleDataReader dr;

     

     

                myConnection.Open();

                dr = myCommand.ExecuteReader();

          

         

               while (dr.Read())

                {

       

                   

                    Response.Write(dr.GetString(0));

                    Response.Write(dr.GetString(1));

                    Response.Write(dr.GetString(2));

                    Response.Write(dr.GetString(3));

                    Response.Write(dr.GetString(4));

                    Response.Write(dr.GetString(5));

                    Response.Write(dr.GetString(6));

                    Response.Write(dr.GetString(7));

                }

             

        }

     

          

    }

     

     

           

     Redirect page

    public partial class _Default : System.Web.UI.Page

    {

     

        protected void Page_Load(object sender, EventArgs e)

        {

     

          

            if (!Page.IsPostBack)

            {

               

                               

     

                LoadData();

     

            }

     

        }

     

     

           

     

        protected void LoginStatus1_LoggingOut(object sender, LoginCancelEventArgs e)

        {

            FormsAuthentication.SignOut();

            Response.Redirect("Login.aspx");

        }

     

        protected void btnShowCal_Click(object sender, EventArgs e)

        {

            Calendar1.Visible = true;

        }

        /************************************************************/

        protected void Calendar1_SelectionChanged(object sender, EventArgs e)

        {

            Project_Due.Text = Calendar1.SelectedDate.ToString("MM/dd/yyyy");

     

            Calendar1.Visible = false;

        }

     

     

     

        protected void LoadData()

        {

         

     

            //load data

          

            OracleConnection myConnection = new OracleConnection(ConfigurationManager.AppSettings["DSN"]);

            OracleCommand myCommand = new OracleCommand("SELECT PROJECT_NAME, PROJECT_DUE, REQUESTED_MANAGER, PROJ_DESCRIPTION, PROJ_CATEGORY, PROJ_STATUS, ASSIGNED_TO, PRIORITY_LEVEL FROM NEW_PROJECTS  WHERE PROJECT_DUE = '" + Calendar1.SelectedDate.ToString("MM/dd/yyyy")   + "'", myConnection);

            OracleDataReader dr;

     

     

            myConnection.Open();

            dr = myCommand.ExecuteReader();

           

           

            while (dr.Read())

            {

               

    Project_Name.Text = (string)dr["Project_Name"];

    Project_Due.Text = (string)dr["Project_Due"]; //this is the problem due date is not binding with the calendar selection date

                Requested_Manager.SelectedValue = (string)dr["Requested_Manager"];

                Proj_Description.Text = (string)dr["Proj_Description"];

                Proj_Category.SelectedValue = (string)dr["Proj_Category"];

                Proj_Status.SelectedValue = (string)dr["Proj_Status"];

                Assigned_To.SelectedValue = (string)dr["Assigned_To"];

                Priority_Level.SelectedValue =(string)dr["Priority_Level"];}

     

     

            myConnection.Close();

           

        }

     

        }

    }

        

     

            

     

              

     

          

                  

                 

       

     

          

      

     

     

    Monday, November 9, 2009 5:13 PM
  • User555306248 posted

    You have already done it

    e.Cell.Text = "<a href='edit_project.aspx?PROJECT_DUE=" + e.Day.Date.ToString("MM/dd/yyyy") + "'>" + e.Day.DayNumberText + "</a>";

    is there any  issue with above code

    Monday, November 9, 2009 10:07 PM
  • User-293064608 posted

    When I click my highlighted calendar date, it shows the date selected but when I redirect to the next page it is not populating the correct selected calendar date.  It is populating 01/01/0001. What am I doing wrong?  This is really weird. Somehow I need to pass the selected date to my next page, how to do that??? Please look through my code and let me know what I am missing. This might be clear to me.

    Tuesday, November 10, 2009 10:15 AM
  • User555306248 posted

    As I alreay told you, you can pass it in query string or Store it in Session so that you can access it on another page 

    Tuesday, November 10, 2009 10:11 PM
  • User-293064608 posted

    Please show me how to pass it in query string or Store it in Session from my calendarselectionchanged code.  That's the part I am confuse about. I dont' know where to begin. 

    Wednesday, November 11, 2009 4:09 PM
  • User-293064608 posted

    Hey Chetan-

    Please disregard this message. I've solved the problem..........YEEEEEY....WHEW! 

    Wednesday, November 11, 2009 5:43 PM
  • User555306248 posted

    Thats nice, you solved the problem. Cabn you just let me know how you solved I mean using QueryString or Session 

    Wednesday, November 11, 2009 10:03 PM
  • User-293064608 posted

    I've used QueryString. 

    Thursday, November 12, 2009 9:23 AM
  • User-293064608 posted

    I got one more question: How do I display project names that's stored in database in my calendar.

    Here's my code-behind (CalendarDayRender):

     protected void Calender1_DayRender(object source, DayRenderEventArgs e)
        {
           
           
            // Declare the query string.

            OracleConnection myConnection = new OracleConnection(ConfigurationManager.AppSettings["DSN"]);
            OracleCommand myCommand = new OracleCommand("SELECT to_date(a.PROJECT_DUE,'MM/DD/YYYY'), PROJECT_NAME FROM NEW_PROJECTS a WHERE upper(a.REPORTS_TO_ID) = '" + Session["UserName"].ToString() + "'or lower(a.REPORTS_TO_ID) = '" + Session["UserName"].ToString() + "' or upper(a.ASSIGNED_TO_ID) = '" + Session["UserName"].ToString() + "'or lower(a.ASSIGNED_TO_ID) = '" + Session["UserName"].ToString() + "'and a.proj_status = 'Active'", myConnection);
            OracleDataReader dr;


            myConnection.Open();
            dr = myCommand.ExecuteReader();

            while (dr.Read())
            {
              
             
                //assign the calendar control dates already contained in the database
                string d1;
                d1 = e.Day.Date.ToString("MM/dd/yyyy");
                Calendar1.SelectedDates.Add((DateTime)dr.GetOracleDateTime(0));

              

                  
                e.Cell.Text = "<a href='edit_project.aspx?PROJECT_DUE=" + d1 + "'>" + e.Day.DayNumberText + "</a>";
             
            }

    Thursday, November 12, 2009 5:10 PM
  • User555306248 posted

    What do you mean by this

    How do I display project names that's stored in database in my calendar.

    Do you want to show Project name in Calendar along with dates 

    Thursday, November 12, 2009 10:02 PM
  • User-293064608 posted

    yes, that's what I mean.  I'm pulling the project name from the database. 

    Friday, November 13, 2009 5:31 PM
  • User555306248 posted

    I am not sure if we can show the project name in calendar. May br for that you need third party control 

    Sunday, November 15, 2009 10:12 PM
  • User555306248 posted

    Any updates on this 

    Tuesday, November 17, 2009 10:08 PM
  • User-2136679076 posted

    when you validate the user, you can catch firstname in session then you can used it whatever you want it.

    in code behind file where the login validation, something like this:

             internal bool ValidateUser(string userName, string passWord)
            {
                SqlConnection conn;
                string currentName = null;
                string firstname = null;

                //// userName must not be null
                if (null == userName)
                {
                    return false;
                }

                //// passWord must not be null
                if (null == passWord)
                {
                    return false;
                }

     try
                {                       
                    //// connect to your  SQL Server.
                    conn = DB connection string;
                    string sqlUserName;
                    string sqlfirstname;
                    //// Create SqlCommand to select passwor and username fields from UserData table given supplied userName passWord.
                    sqlUserName = "SELECT UserName,Password FROM [your table name] ";
                    sqlUserName += " WHERE (UserName ='" + userName + "')";              
                    sqlUserName += " AND (Password ='" + passWord + "')";               
                    SqlCommand com = new SqlCommand(sqlUserName, conn);

                    //// Create SqlCommand to select firstname and lastname fields from UserData table.
                    sqlfirstname = "SELECT FirstName,LastName FROM [your table name] ";
                    sqlfirstname += " WHERE (UserName ='" + userName + "')";             
                    SqlCommand command2 = new SqlCommand(sqlfirstname, conn);
                        
                    currentName = (string)com.ExecuteScalar();
                    firstname = (string)command2.ExecuteScalar();
                    //// Cleanup command and connection objects.
                    conn.Dispose();
                    conn.Close();
                }
                catch (Exception ex)
                {
                    // Add error handling here for debugging.
                    // This error message should not be sent back to the caller.
                    System.Diagnostics.Trace.WriteLine("[ValidateUser] Exception " + ex.Message);
                }

                if (currentName != null)
                {
                    Session["UserAuthentication"] = userName;
                    Session["firstname"] = firstname;
                    ////  Session.Timeout is set in web.config file.
                    return true;
                }
                else
                {
                    Session["UserAuthentication"] = string.Empty;
                    return false;
                }
            }

    then add this line of code to .aspx file you want to display the firstname. for example master.aspx

               <div class="link" id="divid" style="float: right">
                                <asp:LoginName id="LoginName1" runat="server" />                      
                                </div>

     

    and then add this line of code in the .cs file ex:(master.cs) under page_load.

    protected void Page_Load(object sender, EventArgs e)
            {
                ////this can come from anywhere like session, database
                string firstname = (string)(Session["firstname"]);
                LoginName1.FormatString = "Sign in as" + " - " + firstname; ////output: Sign in as - username
            }

    IS this helpful for you???????

    Monday, March 28, 2011 7:01 AM