Results 1 to 32 of 32

Thread: [RESOLVED] On Focus...

  1. #1

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Resolved [RESOLVED] On Focus...

    I have a Login teextbox and I want it to be populated with "Please enter username" or such upon the page loading, no issues there. But when the user tabs or clicks into the textbox I want it to clear the text so its ready for entry. I didnt find anything on a quick search so is there some event that I am missing that I can use for this?

    The textbox control does not have a GotFocus event os I am unsure on this.

    Thanks
    Last edited by RobDog888; Mar 11th, 2006 at 04:28 AM.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  2. #2
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: On Focus...

    That is a client side event, You will have to use Javascript to do that.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

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

    Re: On Focus...

    Not GotFocus. It's onFocus.

    In the onFocus event, call a client side javascript method that first compares the text in that textbox with 'Please enter username'. If they match, then set the textbox's value to an empty string. Else, let it be.

  4. #4

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: On Focus...

    I suppose I should create an external js file for all the js code that will be coming in the days ahead.

    Do you have an outline of the js event? I hate js. Should I pass the control name and its value to the procedure that is going to be called? or can it be done some other way?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: On Focus...

    And In case you just too lazy to write the function here is an example
    Code:
    			<asp:TextBox id="TextBox1" runat="server" value = "Please Enter Username" onFocus = "changeVal()"></asp:TextBox>
    			<script type="text/javascript" language="JavaScript">
    			function changeVal() {
    				if (document.Form1.TextBox1.value == "Please Enter Username")
    					document.Form1.TextBox1.value = ""; 
    			}
    		</script>
    Use [code] source code here[/code] tags when you post source code.

    My Articles

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

    Re: On Focus...

    JS is quite loose. Shuja's shown you how to do this. In the case of this particular function, you wouldn't pass the control's name because it's just a matter of ONE control being processed. If it were a whole bunch of controls, you would pass 'this' as an argument.

    Adding it to a .JS file is your discretion. You may want to start by having it on the same page itself at first and then move it all out later.

    Look out for case sensitivity. It can invoke hours of debugging time.

  7. #7
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: On Focus...

    Quote Originally Posted by RobDog888
    I suppose I should create an external js file for all the js code that will be coming in the days ahead.
    You can put all Javascript in an external js file. Looks like a big ASP project is going on.
    Quote Originally Posted by RobDog888
    Do you have an outline of the js event? I hate js.
    Now is the time that you start loving it.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  8. #8

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: On Focus...

    YES I have a large site to develop and I know just enough HTML/CSS to get by but I only did one small static site so far using asp.net. I want to learn it well.

    The event doesnt seem to be firing

    Btw, Thanks for the help so far guys. I will be posting many threads over the next week


    VB Code:
    1. <td style="BORDER-RIGHT: #b22222 1px solid; FONT-SIZE: 12px; BORDER-LEFT: #b22222 1px solid; WIDTH: 140px; FONT-FAMILY: Verdana, Arial; ALIGN: center"
    2.      vAlign="top" align="center" bgColor="#eeeeee"><asp:textbox id="txtUsername" BackColor="#cccccc" style="FONT-SIZE: 12px; COLOR: #b22222" runat="server"
    3.      Width="110" value="Enter UserName" onFocus="changeVal()></asp:textbox>
    4.       <script type="text/javascript" language="JavaScript">
    5.           function changeVal() {
    6.               if (document.Form1.txtUsername.value == "Enter Username")
    7.                   document.Form1.txtUsername.value = "";
    8.               }
    9.      </script>
    10. </td>
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: On Focus...

    Take a look at your code, you are setting the value to Enter UserName and then in the event you are checking for Enter Username
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  10. #10

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: On Focus...

    w00t w00t! I'm an ASP.NET programmer now

    It was a stupid missing doublequote from the atuomatic formatting that the ide does. Also found that when it did fire it wasnt matching. I guess its case sensitive?

    I didnt know you could place the js code in there that way.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  11. #11

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [RESOLVED] On Focus...

    One more question...
    When I click on the submit button I have it redirect to "#" for testing. When this happens the postback repopulates the login textbox.

    VB Code:
    1. Private Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogin.Click
    2.         Response.Redirect("#")
    3.     End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  12. #12
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: [RESOLVED] On Focus...

    Thats because ASP.NET has a different State Management that classic ASP. Read about state management on MSDN.

    If you want this should not happen then set EnableViewState of the control to False.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  13. #13

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [RESOLVED] On Focus...

    Ok, thanks. I'll look it up.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  14. #14

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [RESOLVED] On Focus...

    I tried setting it to false in the page_load but if i type in a username and submit, it repopulates it with "Enter UserName"
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

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

    Re: On Focus... Still 1 more issue

    You must be calling a function in the body onload that populates that textbox. Instead of calling the function in body load, send a call to it to the output using Page.RegisterStartupScript.

    In your page load event:

    VB Code:
    1. If Not Page.IsPostBack
    2. Page.RegisterStartupScript("myscript","nameofthefunction();")
    3. End If

  16. #16

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: On Focus... Still 1 more issue

    I did this in the page_load event procedure
    VB Code:
    1. If Page.IsPostBack = False Then
    2.             Me.txtUsername.Text = "Enter UserName"
    3.         End If
    4.         Me.txtUsername.EnableViewState() = False
    It appears to work but I wont be 1000% until I finish creating the db and writting the login code.

    Does this look correct now? I did have the textbox being populated in the aspx element tag in the html section.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

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

    Re: On Focus... Still 1 more issue

    It'll do.

  18. #18

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: On Focus... Still 1 more issue

    Thanks
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  19. #19
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497

    Re: [RESOLVED] On Focus... Still 1 more issue

    Actually if you had done your response.redirect to the name of the page "default.aspx" for example, it would not have retained the settings.

    When you redirect to an anchor, it instead of redirecting the page just sends the browser a different URL, but maintains state. It does this to help, not hinder, your coding.

    Just letting you know that you just killed the proverbial fly with an elephant gun.
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  20. #20

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [RESOLVED] On Focus... Still 1 more issue

    Well I like overkill but I just dont have a second page to redirect to yet. I'll test it out with a dummy page.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  21. #21
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497

    Re: [RESOLVED] On Focus... Still 1 more issue

    the second page I speak of is the same page.

    Lets say the "test" page was called "test.aspx" then what I was saying is instead of redirecting to "#" you redirect to "test.aspx" (which is the same page).
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  22. #22

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [RESOLVED] On Focus... Still 1 more issue

    I'm still new to asp.net but I did redirect to the same page and it didnt retain the login name I used. It repopulated it with the "Enter UserName" again. Is this what you meant?

    When it goes to a secondary page it shouldnt be populated at all since they will already be logged in.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  23. #23

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: On Focus... Still 1 more issue

    Ok, related issue still here. The login txtUserName textbox contents should be added to the User_Name session variable but its not retaining or able to even be placed into a label control.

    VB Code:
    1. Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.         'Put user code to initialize the page here
    3.         'Login code
    4.         If Session.SessionID Is Nothing Then
    5.             'code to alert or redirect to login in again
    6.             Response.Redirect("index.aspx")
    7.         End If
    8.         If Session.Item("sesUser_Name") = Nothing Then
    9.             Session.Add("sesUser_Name", "RobDog888")
    10.         End If
    11.         If Page.IsPostBack = False Then
    12.             Me.txtUsername.Text = "Enter UserName"
    13.         End If
    14.         Me.txtUsername.EnableViewState() = False
    15.     End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  24. #24
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: On Focus... Still 1 more issue

    Maybe you left it out accidentally but it does not look like you are inserting the contents of the sesson variable anyway

    Something like:

    VB Code:
    1. If Session.Item("sesUser_Name") = Nothing Then
    2.   Session.Add("sesUser_Name", "RobDog888")
    3. Else
    4.   If Page.IsPostBack = False Then
    5.     Me.txtUsername.Text = "Enter UserName"
    6.   Else
    7.     Me.txtUsername.Text = Session.Item("sesUser_Name")
    8.   end if
    9. end if

    ?

  25. #25

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: On Focus... Still 1 more issue

    Sorry, forgot to post the btnLogin click code. RobDog888 was a test. Like a temp guest user id.
    VB Code:
    1. Private Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogin.Click
    2.     If Session.Item("User_Name") Is Nothing Then
    3.         Session.Add("User_Name", Me.txtUsername.Text)
    4.     End If
    5.     Me.lblUserName.Text = Session.Item("User_Name").ToString 'THIS IS NOT POULATING MY LABEL :(
    6.     Session.Timeout = 15
    7.     '...
    8. End Sub
    Btw, thats a really nice looking forums site in your sig. vBull 3.5
    Last edited by RobDog888; Mar 11th, 2006 at 03:48 AM.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  26. #26
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: On Focus... Still 1 more issue

    is btnLogin your submit button? If so I recommend placing that code in the page load event. Check if you have a username posted and if so add it as a session variable. Elseif check if a session variable is already present and if so place it in the text box.

    Then again, I could just be showing my ignorance of ASP.NET. Sorry

  27. #27

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: On Focus... Still 1 more issue

    This is the home page so to be able to login only once and access the secured pages it needs to check on the page load for if they just refresh or renav to the home page after they already logged in. Now if they havent logged in at all then the pageload will not have a txtUserName content to load into the session var. It needs to ignore the "Enter UserName" auto text htat I had populated in the js in the html for the page as shown by Shuja Alis posted code.

    So it seems that when the postback happens it doesnt pickup the session var.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  28. #28

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: On Focus... Still 1 more issue

    w00t, got it. It was the stupid Session.SessionID check that was throwing it off. This now retains the uisername (without any verification of login yet) and populates a label control with the username and starts the session timeout of 15 minutes and redirects with SSL.
    VB Code:
    1. Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.         'Put user code to initialize the page here
    3.         If Session.Item("User_Name") = Nothing Then
    4.             Session.Add("User_Name", "Guest")
    5.         End If
    6.         If Page.IsPostBack = False Then
    7.             Me.txtUsername.Text = "Enter UserName"
    8.         End If
    9.         Me.txtUsername.EnableViewState() = False
    10.     End Sub
    11.  
    12.     Private Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogin.Click
    13.         If Session.Item("User_Name") Is Nothing Then
    14.             Session.Add("User_Name", Me.txtUsername.Text)
    15.         End If
    16.         Me.lblUserName.Text = Session.Item("User_Name").ToString
    17.         Session.Timeout = 15
    18.         Response.Redirect("https://secure.blah.com")
    19.     End Sub
    Now I just need to clear the txtUserName box and clear the lblUserName upon page load to take out the control name thats in it by default.

    another step closer.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  29. #29
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: On Focus... Still 1 more issue

    Glad to not be of assistance

  30. #30

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: On Focus... Still 1 more issue

    But a second set of eyes is always a help. I noticed that when you reposted my code my sesUser_Name var was named differently then it was in the btnLogin clck event.

    Now I am multi-tasking and in the middle of creating the users sql table.

    Thanks everyone
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  31. #31
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: On Focus... Still 1 more issue

    Quote Originally Posted by RobDog888
    But a second set of eyes is always a help. I noticed that when you reposted my code my sesUser_Name var was named differently then it was in the btnLogin clck event.

    Now I am multi-tasking and in the middle of creating the users sql table.

    Thanks everyone
    You are still here.

    I though you would have finished your project by now.

    All the best.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  32. #32

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [RESOLVED] On Focus...

    Thanks but unfortunately I am a noob at asp.net so its going to take some time.

    Ps, I have 5 or 6 hours left to finish the entire login and security part.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

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