Solved

ASP.Net - Help translating code in Pade_Load event

Posted on 2013-05-22
5
388 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
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 …
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

929 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now