transfering value from one page to another in windows phone 8 - windows-phone-8-emulator

i have three pages a,b and c all pages have checkbox control.i transfer the value of one control on page b to page a by query with navigation method and when i transfer page c value to page a the previous value that is transfered to another control previously is removed on transfering value how can i save it so that it remain on the page.
please help me in finding solution
Thanks

Use PhoneApplicationService.Current.State.
It works like session variables.
This is how you can use it:
Page 1 - //saving the value
variable 1=[your value];
PhoneApplicationService.Current.State["any session variable name"] = variable 1;
Page 2 - //retrieving the value
variable 2 = PhoneApplicationService.Current.State["any session variable name"];

Related

ASP.Net - Using variable value in different button click events - VB

I have a multiview with 4 views. To switch between the views I use 4 buttons and switch the multiview's activeview index to the relevant view inside the click event of each button.
In each view there are various controls to capture data. There is then a submit button at the bottom of the final view to write all the data to a database.
What I want to achieve is to capture a time stamp of when the user clicks the button to move to each view (which will ultimately be written to the database). I can assign a timestamp to a variable by using the below code in the click event of each of the 4 buttons
Dim phase1TimeStamp as string = DateTime.Now.TimeOfDay.ToString()
The problem is, when I come to write the records to the database in the click event of the submit button, it cannot see the values assigned to these time stamp variables.
Is there a way I can pass these variable values to the submit button click event or is there a different way I can achieve this altogether? Thanks
The easiest way to do this is probably by saving the variable to session, then retrieving it. You didn't say if this was ASP .NET Web Forms or MVC, so I will give you an option for each. MVC has a few different ways you can achieve this (ViewData, ViewBag, TempData, or directly to Session). I'm not quite as familiar with Web Forms but you can at least save to Session.
Web Forms
to save to session:
HttpContext.Current.Session("phase1TimeStamp") = phase1TimeStamp.ToString()
to retrieve it (you may have to cast it, depending on the type and your VB settings):
Dim myVar as String = HttpContext.Current.Session("phase1TimeStamp")
MVC
to save to session:
Session("phase1TimeStamp") = phase1TimeStamp.ToString()
to retrieve it:
Dim myVar as String = Session("phase1TimeStamp")
A note about MVC: If you want this to work across multiple sessions (I.E., for different users or even for the same user but with multiple tabs open), you will need to append the identifier ("phase1TimeStamp") in this case with some sort of unique identifier.
You can store the values in Session cache, like this:
Session("MultiView1_Clicked_DateTime") = DateTime.Now.TimeOfDay.ToString()
Session("MultiView2_Clicked_DateTime") = DateTime.Now.TimeOfDay.ToString()
Session("MultiView3_Clicked_DateTime") = DateTime.Now.TimeOfDay.ToString()
Session("MultiView4_Clicked_DateTime") = DateTime.Now.TimeOfDay.ToString()
The Session value will exist in memory across page requests.
Note: You can name the Session key whatever you wish, but to get the value back out you need to match that key name exactly. Also, everything in Session is stored as an Object so you will need to cast the value to a String when you want to retrieve the value.

How to properly increment a specific variable in aspnet?

Im trying to increment this specific element in ASPnet. A user selects a specific item in the dropdown box, and it increases the quantity as the user selects.
If DropDownList1.SelectedIndex = 1 Then
DropDownList1.SelectedIndex = 0
intDonutqty += 1
txtDonut.Text = intDonutqty
End If
Everything else works fine, but for some reason it just stays at 1 without incrementing.
Thanks for the help
Variables in the page are local to the instance of the Page class, and the instance is only used to handle one request. When you make a postback and the next request comes for the page, a new instance of the Page class is created, so you will get a brand new variable which starts out at zero.
To keep the value between requests, you either have to store it in a session variable, in the ViewState, in a cookie, or a hidden field in the form.

Accessing GridPanel base parameters

I have search box and a GridPanel with paging. You enter search criteria click a button and the results display in the GridPanel...simple
I have notice a bug, when I search for something that returns 5 pages of records, go to the last page, then perform another search that returns 1 page I am on page 5 of 1.
The start page parameter is in the BaseParameters of the GridPanel, how can I access this to reset it back to 0 when a new search is performed?
This is probably very easy but I am completely new to ext.net
you can invoke the changePage() method of the PagingToolbar. This method excepts an Integer for the desired page number. Check out the link below for more details.
http://docs.sencha.com/ext-js/3-4/#!/api/Ext.PagingToolbar-method-changePage
Thanks,
Gav

How to create a form with variable no. of field set

I have to design a page for user information, for some background verification purpose, at my work. I need a set of fields for address, total count of which will be selected by user to update the form with that many fields. So, if user selects 3, form will have 3 set of address fields. Similar concept for work and education details.
Right now, I am passing the count to a handler page, which checks total count, and return it along with querystring, back to the main page. I am able to update the no. of fields, this way, but, all values are lost, once I return to the form. There are a lot of fields to even use session object for every value. Also, it resets the count of other such field set to 0. So, if I select 4 in address field, it renders four set of address fields, but fields for other details are gone.
I need to know, if it is possible to update the fields, using just one page, instead of creating a handler file to handle the redirect, so that I don't lose other data.
Sorry, for sounding a bit confusing. Will update the question, if needed.
Edit:
Similar blocks are there for education and work details. I want the update button to update the block, with that many fields, while retaining the values already entered by the user.
I have finally shifted the update code to one page. And the total count of blocks, is calculated by this way.
if request.form("addresscount") <> "" then
varaddresscount = request.form("addresscount")
else
varaddresscount = 1
end if
varaddresscount is used to loop through the html code which renders address fields. Even with this method, if I click on update button to change the total field count, every value entered by user is reset to default. Is there a way to retain the no. of fields without using session object, as there are way too many fields for which I have to store the value in session.
Why not have just a "add address" button that, whenever clicked, adds a extra set of input boxes using Javascript? That solves a lot of your problems regarding retaining the data on already filled in fields AND it makes it easier for the user.

Display data from database using selected value from combo list.. (ASP)

Does anyone know how to retrieve and display data from database using combo list? What I mean is this..I have a form..in the form there is a combo list and two textfiels..the user need to choose their company using that combo list..once they have chose their company, the address and contact number of the company will be display in the next two textfields called CAddress and CContact..for example, if the user chose company ABC..how can I display the company ABC address and contact number in those textfields? Need help. Thanks.
first of all you could use javascript and make a call ajax to an asp page passing the id of the company ... in that page you can jsut response.write the infos u need as a xml format ... even csv format would work ... then jsut take the response and write it in the textbox

Resources