Solved

ASP.Net - Help translating code in Pade_Load event

Posted on 2013-05-22
5
396 Views
Last Modified: 2013-05-22
Good Day Experts!

I am back on my journey to learning ASP.Net.  Currently, I am a VB.Net programmer.
I have attached a text file with code that is in the Page_Load event for the Login.aspx of the website.  

Can you help and translate what is happening in the code?  Also, "If Not Page.IsPostBack Then"...will it ever be Page.IsPostBack and not run the code? Also, "If Not Request.Cookies("myCookie") Is Nothing Then"...will the cookies ever not be nohting?

Thanks,
jimbo99999
0
Comment
Question by:Jimbo99999
  • 3
  • 2
5 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39187932
I have attached a text file with code...
What file?  : )

Then"...will it ever be Page.IsPostBack and not run the code?
Yes. The first time a page is requested is not a post back. Clicking a button or interacting with some other control on the page (typically) triggers a post back.

Also, "If Not Request.Cookies("myCookie") Is Nothing Then"...will the cookies ever not be nohting?
Sure.
0
 

Author Comment

by:Jimbo99999
ID: 39187951
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 39187979
"If Not Page.IsPostBack" is checking as to whether or not the page is being initially requested (e.g. a user types the URL into the browser's address bar). If this is the initial request of the page, then the session is cleared (just in case an existing session is still in memory, I presume). Then you are checking to see if the browser sent a cookie named "myCookie". If it did, then you extract the cookie from the request object. From this cookie you are extracting the values of the "ITSusername", "ITSP", "AMARKN" (commented out), and "ITSR" fields, and using them to set up the states of various controls (e.g. text boxes and check boxes). Finally, you are checking a code-behind field named "ModError" for any text. If it has text, then its text is placed into a label on the page.
0
 

Author Comment

by:Jimbo99999
ID: 39188126
Excellent, thanks for the explanation.  My next step of working through the code I put a breakpoint on the first line behind the login button.  After entering my username and password and I click the Login button...to my surprise the first line of code that is executed is in the Page_Load event of the Login.aspx!  So, once I am in the website I hit the Logout button and same thing...to my surprise the first line of code that is executed is in the Page_Load event of the Login.aspx!  I can't figure out why it happens and where in the code it tells it to go back to the Page_Load event of the Login.aspx page.

Do you have any thoughts that might help me understand?

Thanks,
jimbo99999
0
 

Author Closing Comment

by:Jimbo99999
ID: 39188283
Excellent...thanks for the help.
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question