Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
hello guys.am working on a project of an online admission system where students can apply online for admission..

Have been able to get my application to a certain stage but am stock.

so here is my scenarion,i have to button on my each of my pages,the submit button responds to a post request which actully saves the data into the database.

However,when a user after a user has finished saving the record into the database,i return the view back to the user to allow them make changes as required.that also works perfectly..

now my issue,is when i click on the other button lets say next,i want to pass along the studentID to the next page,so the student can fill out the other pages and save their records as appropriate.
The only solution have seen so far is to use a redirect action,but the problem with the redirect,it gets triggered when the user clicks the submit button,and when that,the user cannot make changes to the form as required.

so i need the next button to help triggered the event to pass the studentID as a url parameter to my other views..

Thanks in advance
Posted
Comments
Sergey Alexandrovich Kryukov 14-Feb-15 3:22am    
Lean session states and HTML Web storage...
—SA
[no name] 14-Feb-15 4:00am    
Yeah session states can help you while loading store studentID as session variable!

1 solution

There are many possible solutions to this, and you can use any of them. It is your application and you have to define the actual logic that would be working on the back-end of your application to make this process look like working. I would try to give you a few of these examples, you can see for which one would suit you.

If you're using a form, and upon submit you redirect the user to the next page to fill the next form. Then using an input field would be a good one for you, you can embed the UserID of the user (student in your case) inside the form, as a hidden field. Which won't be visible to the user, but you will be able to use its value on the server-side to perform student-specific actions. Have a look at the following form,

HTML
<input type="hidden" name="studentID" value="@ValueFromServer" />


The ValueFromServer would be populated by server and would contain the UserID. On the server, you can access this value as this code,

C#
// Match the name of the input field from the form that was submitted
var userId = Request["studentID"];


Furthermore, you can first allow the users to register on your website, and then use their logged_in state and their ID to perform these actions (which would be still same as above, but just that the scope of the value would increase). This way you can get the UserID of the student on every page inside your application.

You can also save the values in the cookies, localStorage[^] or many more methods. It depends on how you try to be using it.

Never store any sensitive information on the client-side cookies; such as passwords, credit card information etc.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900