Pass data between Meteor pages - meteor

I have a Meteor application which is a POS system. Once a transaction has been completed a receipt is populated on screen, giving the user the option to print. As the receipt is an entire page in itself (for formatting to correct width etc) it is displayed in an iframe, so a different page to the page displayed for the Till.
Currently the receipt page is subscribing (using SubsManager) to the same collections as the Till page and extracting the data required to form the receipt however this feels very wrong. What I want to do is to simply create a JSON object in the till page containing all data required for the receipt, and just pass it to the receipt page. I'm struggling with how to actually do this though - my setup is using FlowRouter / Blaze. Thinking in a traditional server/client heretic approach I would simply have POSTed this data to the page but it doesn;t seem to be possible here. Is there a standard way to achieve this?

Related

multiple updates in one submit in SPA page

I have a web page written in ASP.net where it finds a list of employees, displays them in a listview and allow the user to change different statuses for each employee.
On each row I have employee information like name, date of birth, address and then 4 status fields that are displayed as checkboxes and a comment field where the user can type a comment explaining why they changed a certain status.
Currently in Listview, there is an edit, delete button when they click edit, the checkboxes and text field are displayed the user updates them and click save.
asp.net will do a postback to save the changes for this row and then fetches the data again to refresh the list.
The problem I am having is the list is very large (more than 3000 names), so I am using pagination to show 50 to 100 names on each page. This is still a big performance problem because after every line update a query needs to run to fetch those names again, and with ASP.NET the server is generating the html and passing everything to the browser.
The customer wants the page to be mobile friendly too, so I am thinking to redo the page using Angular on front end with web-api or mvc.net on back end that returns JSON.
My question is there an easy way to do this and allow the user to change the status for multiple employees on the same page at once and then click one submit to update all the changes? if I do it this way, there will be less queries to run and it will be faster for the user because they don't have to wait after every line update.
Any examples will be greatly appreciated, unless there is a different way to implement this, in this case please let me know.
I have a thought that may work.
On load render names and use pagination.
Then use ajax to send the post to server and change data in database.
When editing has returned successful then only change the values that have been edited using javascript for the user to view.

Cross-page posting with target _blank leaves source page unfunctional

I'm trying to describe it in as few steps as possible:
I have Page1.aspx with lot of controls, and Preview and Save button among those. I also have Page2.aspx that is the redirection target of a Preview Button click.
Since I need all the controls selections from Page1 to draw a preview on Page2 the redirection is done with setting Preview's PostBackUrl.
I also must have preview shown on a new tab or window so I used onClientClick="aspnetForm.target='_blank'" for Preview button definition.
Save button-click callback, after storing data to a database does redirection to some Page0.aspx (initial list of reports - the subject of the code)
Preview button works fine - a preview renders in a new tab, but when I go to the old tab and click on Save, I see from debugger, that firstly Page2.aspx(?) and secondly Page1.aspx are loaded. Then all the data is stored in the db, but though Page0 redirection is executed Page1.aspx stays loaded in the browser.
I have no idea what processes are behind this. Could one who knows give me an insight? Or if you consider my approach impossible to implement give some idea how to do the same?
If it's of importance, everything on the Page1 is located in an update panel.
Thank you very much for replying
In ASP.NET there are basically zero (0) circumstances in which you will ever send form data from one page to another. Although what exactly you are trying to accomplish is vague, you can consider some of the following:
Isolate unique operations/systems to a single page. If you have something like a User Profile, don't have three different aspx pages; just use a single page for the user or admin to manage that data / functions. Postback events are your friend.
Understand the difference between ViewState and traditional form data. I'm guessing that if you're trying to post form data from one page to another, you probably don't understand the point of ViewState. Using a single page to maintain temporary data that the user is currently working with is a great use for ViewState. If you want the data to appear on another page then you need to consider the data from the previous page as final and thus should be saved to a database or some other medium.
These are just some general guidelines because there is no exact answer to your problem without saying something generic like "You're doing it wrong." I would recommend starting by never again trying to post form data from one aspx page to another.

ASP.NET and XML for each hit to website

I have a question to understand the concept of ASP.NET with each client browser.
I am trying to update the XML on server when a user hits a particular page on my website.
This page is dynamic, but too large so I want it to load using an XML file also I have several drop downs on the page when user changes the value in drop down, I need to refresh the data based upon the selection, additionally my drop down is a custom designed here I do not get and selectedIndex change event.
So I'm using JQuery to get the changed value in my drop down and planning to read XML from jQuery and display the data.
But since the XML is updated on hit of the page on server, I want know, if multiple users hit the same page, will the data displayed as per each users selection or it will mix the data and show the last hits record.
If I'm not mistaken about your question, you basically ask the following:
You have an XML file, which is updated, on some event from user. The page, which is displayed to the user is based on this XML file. What info will users see, when multiple users are working with the application?
This greatly depends on how you are using that file. In general, if you try to write that file to disk each time, users will see the last update. Basically update from the last user.
However, you can synchronize access to this file, write the file on per-user basis and you will see a per-user output:
<data>
<selectedData user="user name">123</selectedData>
<!-- and so on -->
</data>
UPDATE:
For anonymous users this would not work well. However, if you need to store the selection only for the current user, you can use SessionState and not an XML file.
I would like to introduce a new way that it helped me to answer my above question.
What i did here is
on Page load we added all the information related to each section in different hidden fields.
suppose i have three section with my custom drop down!
What exactly we implemented is that on click on my custom drop-down, we separated the values from the hidden field with the separator we entered and displayed the data accordingly, small part of logic but it helped in displaying the data without post back.
and Jquery helps a lot to me for just changing the inner html of my block.

Best way to do paging in a .NET page

Hope you are having a great day.
I have a page where I let users browse related items (photo albums) posted by other users.
I show the album thumbnail, title, author, ratings views and category for each albums.
Now the number of related items can get large say 500 photo albums is related to a album user is viewing. I just show first 20 and drop a link saying 'View All'
Once the user clicks View All I take him to a page where I display 50 items per page.
Option 1: using a repeater\grid control
When user clicks a page I get the right items (using sql) and bind the result to the grid
The page is refreshed and user sees new page. So one big request and user sees all thumbs.
Option 2:
when user clicks the pager I use Ajax to get the thumbnail file name, title, rating, author etc.
Then I build the grid manually and set the src attribute of element using javascript
Then I append the resulting grid to a div. User sees the new grid without page refresh.
My concerns:
I have the thumbnails and all image files in file system (not database)
In second approach javascript will send 50 separate request to web server to get the image files. This will cause a lot of requests on the web server. Large concurrent users will flood the server with image file requests.
What is the best & efficient way to do paging and storing user files?
Is my app going to die by putting the images in file system since the app should handle millions of photos?
If you aren't already using one, a CDN (content delivery network, like Amazon S3 etc) will help (so you can download from multiple places concurrently).
Also, instead of requesting one image, request a page from the server. Let the server decide how many images to return.
You could try some css sprite techniques.
Definetely you shouldn't use Option 1 since it would take a lot of time for the page to load
Aldso the second alternative id not so good either.
You can use your GridView/ListView control but use server side paging to get the data. This way you could load only the information that is needed per page.
You can see how to implement a stored procedure for server side paging here : http://www.sqlteam.com/article/server-side-paging-using-sql-server-2005
Then you can bind the individual page the PageIndexChanging event handler of your Gridview
so only the page that is needed is actually loaded.

can i repost or carry POST data (if so, can i do it with redirects?)

I want to redirect the user to another page to fill out a captcha but i would like to keep the post data, and if the captcha pass to send it 'back' and complete the previous page action.
When/if the user succeeds i like to add an captchaPass=true and would like access the post data and continue processing. Right now i am using redirects but ATM i am not required to use it.
Is it possible to carry the post data? keep in mind i may the user access multiple pages so separating data and not having a mixup is necessary.
One idea is to get and save all posted data [1] on the captcha page, and then recreate a middle white page with this form data and automatically make a new post to the previous page.
Can this work with out any issues with hash checks and security ?
Is there a better idea with out this white redirect page ?
[1] One other issue here, how to send this posted data with the redirect ? and not change the url - or make it too big to accept it. Keep in mine that a server transfer may not good idea because is complicate the thinks on captach post back.
Update 1
The basic idea here is how some one capture the full post back of a page, show a different one page and then send the post back data to the original first one.
The reason is to stop a bad user, or an attacker bot program that try to bring down the pages/server by making many post back from different pages in short time. All that happens with out javascript, and most attackers use custom made programs that just make post of data to all page together try to bring down the system.
For example, if a page have a search box, is very easy for most of the the site to bring them down by start making hundred of random search with wildcard (called and Dos Attacks using SQL wildcards) and make the sql server and the computer spend his time and cpu to search and search thinks. So to prevent an attack like this you need to recognize multiple post backs from the same computer, and then the next step is to redirect him to a captcha page to block him out in case that is a computer program.
Other example, many page have email submit, very easy you can submit hundred times the email of his and full his mail box in no time with hundred of emails, or on a store to place all items on the cart again and again and full the database with stuff like that.
So ajax and javascript is not working in this case, and we need a way to redirect him after the post back to a page that can check if is a real user or an attacker and stop him - but if is a real user must return back to his normal action.
Update 2
This all must be done in a general way, eg on BasePage, or on Global.asax or somewhere that is independed from the content of any page. Because we try to prevent a DoS attack, or multiple submit anywhere on any random place of any random page.
Yes I know how you can place a captcha on the contact page, but this is not what this question was first asked for - this questions asked how can carry post data to one different page, keep them there and then resend them back to the original one.
The obvious solution is to read all post back, and save them on the form, and then read them back and make on fly a form only with that data and make the post back. Here I am asking if there are any other better than this solution.
Other Applications
There is also the case that a user is inside a page that request authentication, but the authentication ticket has expired, and the user make post back. In this case we need to keep somewhere all the posted back data, to proceed with the login page, and resend them back to the first page that request the authentication.
Sure, just write the form data out to the captcha page in hidden elements with the additional captcha fields added to the form. Have your submit action post the whole thing back to the original. Using ASP.NET it's probably easier to have the captcha written to the same page with the form fields hidden, but you can do cross-page postbacks as I've described above.
Cross Page Posting might help you.
Why not implement the CAPTCHA with AJAX? Load the captcha object and form with Javascript in a div perhaps displayed lightbox style, accept the user input and post it to your server for validation, hence continue with the users post request or keep them there until they get it right (or cancel).
A more specific situation example:
Give the form submittal button an onClientClick value of some Javascript function. This function decides if this particular form needs a CAPTCHA. If it does it loads an interface for taking the CAPTCHA (which you'd need to do with some server-side code) and inserts the CAPTCHA's input element to the form that the user clicked to submit.
Once the user has entered the CAPTCHA input and clicks some button whose click event is bound to return to your first JS function, the Javascript intercepts this action and posts the full form, all the data from the original form and the CAPTCHA for validation. Your server script can now process all this at once!
This is the best solution I can think of that works similar to how you've asked, but I can't imagine why you want to perform the CAPTCHA on a different page.
Server.Transfer with MultiViews, Panels like control is fine with you? In this way, no need to bother about the Data Maintenance and Postbacks. You can do the validations in javascript.
You can keep both functionality in the same page to avoid moving data from one page to another page/Bring the data back to original page. You can utilize Session for this intermediate operation. Set it back to associated controls across Postback. You can create a class, Instantiate it and Initialize the control values in this class object. Save class object in Session. On Postback, You can reassign the values to the associated controls. This will definitely keep the things simple and without much complexity.
Doubts ?

Resources