Solved

ASP.Net - Help translating code in Pade_Load event

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

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 74

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

705 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

20 Experts available now in Live!

Get 1:1 Help Now