[Show all top banners]

user01
Replies to this thread:

More by user01
What people are reading
Subscribers
:: Subscribe
Back to: Computer/IT Refresh page to view new replies
 ASP .Net - How to restore fields
[VIEWED 4640 TIMES]
SAVE! for ease of future access.
Posted on 11-10-16 9:34 AM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

I need to restore first and lastname from cookie, please help. I am able to retreive the firstname, but can't get it to work when it comes to retrieving the second field (lastname). Here is what I have working for the first field:

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
if (!(Request.Cookies["FirstName"] == null))
txtFirstName.Text = Request.Cookies["FirstName"].Value;


Thanks
 
Posted on 11-10-16 10:03 AM     [Snapshot: 22]     Reply [Subscribe]
Login in to Rate this Post:     1       ?     Liked by
 

add your second field to cookie and retrieve it using same way you doin for first field.
 
Posted on 11-10-16 10:28 AM     [Snapshot: 55]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

How do I go about including the second field?

Do I need to create another Load?

Need format plz
 
Posted on 11-10-16 12:25 PM     [Snapshot: 107]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 
 
Posted on 11-10-16 1:03 PM     [Snapshot: 150]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 
 
Posted on 11-10-16 1:09 PM     [Snapshot: 151]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 




Getting an error on line 34 now. I need the check out page to restore fname and lname. It worked using the first code for first field, but doesn't seem to work for the second field.

 
Posted on 11-10-16 1:14 PM     [Snapshot: 157]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

After selecting continue it will go to check out page with items in cart. Next page also has btn that allows me to go back which is supposed to restore cached fname and lname and display it on respective fields. The problem I seem to have is that it only seems to work for the fname field
 
Posted on 11-10-16 1:59 PM     [Snapshot: 180]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Check the property of the textboxes. Enableviewstate set to True. Lets see if that solves the state issue
 
Posted on 11-10-16 2:00 PM     [Snapshot: 182]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

add {} braces when checking for cookies is null or not. when you load you page at first the cookies are not set that's why you are gettin that exception.

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)

if (!(Request.Cookies["FirstName"] == null) && !(Request.Cookies["LastName"] == null))
{
TextBox1.Text = Request.Cookies["FirstName"].Value;
TextBox2.Text = Request.Cookies["LastName"].Value;
}
}
 
Posted on 11-10-16 2:01 PM     [Snapshot: 186]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Also, remember if you have more than one line of code in you if ALWAYS PUT CURLY BRACES around if.
 
Posted on 11-10-16 2:09 PM     [Snapshot: 189]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Many Many thanks to everyone. {} did the trick.

Thanks again.

 
Posted on 11-10-16 2:09 PM     [Snapshot: 200]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Yes cr7. There is no curly braces so its just taking one line after the condition. Lol
 


Please Log in! to be able to reply! If you don't have a login, please register here.

YOU CAN ALSO



IN ORDER TO POST!




Within last 30 days
Recommended Popular Threads Controvertial Threads
TPS Re-registration case still pending ..
मन भित्र को पत्रै पत्र!
Guess how many vaccines a one year old baby is given
अमेरिकामा बस्ने प्राय जस्तो नेपालीहरु सबै मध्यम बर्गीय अथवा माथि (higher than middle class)
emergency donation needed
Travelling to Nepal - TPS AP- PASSPORT
Morning dharahara
nrn citizenship
जाडो, बा र म……
1974 AD Pinjadako Suga Remixed
Susta Susta Degree Maile REMIXED version
Elderly parents travelling to US (any suggestions besides Special Assistance)?
कल्लाई मुर्ख भन्या ?
ढ्याउ गर्दा दसैँको खसी गनाउच
NOTE: The opinions here represent the opinions of the individual posters, and not of Sajha.com. It is not possible for sajha.com to monitor all the postings, since sajha.com merely seeks to provide a cyber location for discussing ideas and concerns related to Nepal and the Nepalis. Please send an email to admin@sajha.com using a valid email address if you want any posting to be considered for deletion. Your request will be handled on a one to one basis. Sajha.com is a service please don't abuse it. - Thanks.

Sajha.com Privacy Policy

Like us in Facebook!

↑ Back to Top
free counters