Solved

ASP.Net - Help translating code in Pade_Load event

Posted on 2013-05-22
5
402 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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 …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

730 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