locked
problem of the client that changes the Url and skip the pages that he don't want to fill RRS feed

  • Question

  • User858909527 posted

    I have a web form asp.net project that contains multiple pages for the client to insert an application. The first page contains personal information about the user when he click next button he will go to the second page to fill information about the application that he want when he click on the next he will go to the third page that contains attachments he should attach and when he attach them and if he click on next he will go to the last page to confirm and pay. But I discovered a big problem which is when the user change the page name in the url above, it will pass him to the page that he want even if he didn't attach anything or if he didn't complete his personal information. Although that, I put the fields all of them required and if he didn't fill them he will see a message that show that he didn't complete the fields. I don't want the user to skip the pages as he want. What should I do for this problem? 

    Monday, March 18, 2019 10:27 AM

All replies

  • User-1225226813 posted

    Hi, 

    You need to create a back end check list that each of your pages can cross reference when loaded.

    Create a simple struct class for each case submission which contains a check list of requirements. 

    Then as each page is submitted, check that your submitted data meets the requirements and updates the struct to say its passed, then allow it to move to the next page. if it fails, then show a message to say can't move on.

    Also have every page check the previous entries in the struct to make sure they haven't been skipped by changing the URL.

    This below isn't finished, but just an idea.

    using System;
    
    namespace MyChecklist
    {
        partial class Check
        {
            public class MyChecklist
            {
                private int SessionID { get; } = 0;
                public bool page1 { get; set; } = false;
                public bool page2 { get; set; } = false;
    			public bool page3 { get; set; } = false;
    			public bool page4 { get; set; } = false;
    			
    			public MyChecklist() {
    				// assign your session ID.
    			}
    			
    			public static performCheck(int pageID, bool CheckWasOk){
    				// check and update here.
    				
    				if (pageID == 1) {
    					page1 = CheckWasOk;
    				}
    				if (pageID == 2) {
    					page2 = CheckWasOk;
    				}
    				// etc.
    				
    			}
    			
    		}
    	}
    }

    Monday, March 18, 2019 2:53 PM
  • User-1174608757 posted

    Hi zalnaser,

    According to your description,I suggest that  you could use validation control. Web Forms has provided specific control to realize that users must enter information in the control like textbox, else the validation control which corresponds to the textbox will send error message the will not allow to submit the form . In this case you should use RequiredFieldValidation control . Here is the link ,I hope it could help you. 

    https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.requiredfieldvalidator?view=netframework-4.7.2

    I have made a sample. You could see as below:

    aspx:

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
    
              Name:  <asp:TextBox ID="T1" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="T1" ErrorMessage="Name couldn't be null"></asp:RequiredFieldValidator><br />
    
              Age:<asp:TextBox ID="T2" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="T2" ErrorMessage="Age couldn't be null"></asp:RequiredFieldValidator><br />
                <asp:Button ID="Button1" runat="server" Text="submit" />
            </div>
        </form>
    </body>
    </html>
    

    You could see :

    Best Regards

    Wei

    Tuesday, March 19, 2019 2:31 AM
  • User858909527 posted

    Hi zalnaser,

    According to your description,I suggest that  you could use validation control. Web Forms has provided specific control to realize that users must enter information in the control like textbox, else the validation control which corresponds to the textbox will send error message the will not allow to submit the form . In this case you should use RequiredFieldValidation control . Here is the link ,I hope it could help you. 

    https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.requiredfieldvalidator?view=netframework-4.7.2

    I have made a sample. You could see as below:

    aspx:

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
    
              Name:  <asp:TextBox ID="T1" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="T1" ErrorMessage="Name couldn't be null"></asp:RequiredFieldValidator><br />
    
              Age:<asp:TextBox ID="T2" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="T2" ErrorMessage="Age couldn't be null"></asp:RequiredFieldValidator><br />
                <asp:Button ID="Button1" runat="server" Text="submit" />
            </div>
        </form>
    </body>
    </html>

    You could see :

    Best Regards

    Wei

    Already I used use RequiredFieldValidation control and I face the same problem.

    Tuesday, March 19, 2019 7:46 AM
  • User858909527 posted

    Hi, 

    You need to create a back end check list that each of your pages can cross reference when loaded.

    Create a simple struct class for each case submission which contains a check list of requirements. 

    Then as each page is submitted, check that your submitted data meets the requirements and updates the struct to say its passed, then allow it to move to the next page. if it fails, then show a message to say can't move on.

    Also have every page check the previous entries in the struct to make sure they haven't been skipped by changing the URL.

    This below isn't finished, but just an idea.

    using System;
    
    namespace MyChecklist
    {
        partial class Check
        {
            public class MyChecklist
            {
                private int SessionID { get; } = 0;
                public bool page1 { get; set; } = false;
                public bool page2 { get; set; } = false;
    			public bool page3 { get; set; } = false;
    			public bool page4 { get; set; } = false;
    			
    			public MyChecklist() {
    				// assign your session ID.
    			}
    			
    			public static performCheck(int pageID, bool CheckWasOk){
    				// check and update here.
    				
    				if (pageID == 1) {
    					page1 = CheckWasOk;
    				}
    				if (pageID == 2) {
    					page2 = CheckWasOk;
    				}
    				// etc.
    				
    			}
    			
    		}
    	}
    }

    Can you discuss more please with screenshots?

    Tuesday, March 19, 2019 7:56 AM
  • User-1174608757 posted

    Hi , zalnaser

    According to your description,could you please share the detail of  your  codes both in front end and  code behind?It will help us to solve your  problem.

    Best Regards

    Wei

    Tuesday, March 19, 2019 8:19 AM