dcsimg
Results 1 to 6 of 6
  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    12,295

    Having issues with querystring when submitting data

    Below are two routines from a aspx page.
    The first time this page is called it is passed a mode=Parent and that seems to work fine
    The intention is that when the Next button is clicked it will either recall itself with a mode of child or call the confirm page.

    What I am seeing is that after hitting next the page reloads with the mode=parent before the break point in the next routine is hit. When it gets to the next button routine it does not have the value for children and is being prevented from adding the next child.

    On a previous form the user would enter a number of children to enter. If that number is greater than 1 then the child form should run as many times as needed but for some reason It is loosing that child value and the page load routine never gets the mode=child.

    I have placed the children value in a text box as a test and can see that it is there and valid but when the next button code executes the var is empty.

    Any ideas why this is happening or what I need to change to prevent it.

    Code:
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Dim Mode As String = Request.QueryString("mode")
    
            If Request.QueryString("mode") = "Parent" Then
                parentid = Request.QueryString("ParentID")
                Name = Request.Form("txtName")
                Address = Request.Form("txtAddress")
                City = Request.Form("txtCity")
                State = Request.Form("txtState")
                Email = Request.Form("txtEmail")
                Phone = Request.Form("txtPhone")
                Contact = Request.Form("txtEContact")
                ePhone = Request.Form("txtEPhone")
                Children = Request.Form("txtChildren")
                If parentid <> "" Then
                Else
                    Child = 1
                    AddParentToDB()
                End If
            ElseIf Request.QueryString("mode") = "Child" Then
                Child = Val(Request.QueryString("Child"))
                Children = Request.QueryString("of")
                txtParentID.Text = Request.QueryString("ParentID")
            End If
            txtChildID.Text = Children
        End Sub
    Code:
    Protected Sub btnNext_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnNext.Click
            lblMessage.Visible = False
            If ValidateChild() Then
                AddChildToDB()
                Children = txtChildID.Text
                If Val(Child) < Val(Children) Then
                    Server.Transfer("reg2.aspx?mode=Child&Child=" & (Child + 1).ToString & "&of=" & Children & "&ParentID=" & txtParentID.Text, True)
                Else
                    Server.Transfer("regconfirmation.aspx?Mode=Confirm&Children=" & Children & "&ParentID=" & txtParentID.Text, True)
                End If
            End If
        End Sub
    Last edited by DataMiser; May 3rd, 2018 at 09:18 AM.

  2. #2
    Hyperactive Member
    Join Date
    Nov 2017
    Posts
    323

    Re: Having issues with querystring when submitting data

    Your description of what is happening probably makes perfect sense to you, but I found somewhat convoluted and confusing, especially this sentence:

    What I am seeing is that after hitting next the page reloads with the mode=parent before the break point in the next routine is hit.
    Not sure what break point in what routine you are talking about.

    In any event, I guess one question I would pose based on just looking at the code is how is the "Child" variable ever being populated with a value in btnNext_Click?

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    12,295

    Re: Having issues with querystring when submitting data

    It is confusing me as well, maybe that is why my description is a bit muddled

    When the page is initially called it is called from a different page and passed mode=parent as part of the query string.
    That part works as expected. Once the user has entered data and hits the next button is where things go off the rails.

    I set a break point at the top of the page load routine and check the mode var in the query string and it shows parent.
    I set a break point in the next button code just above the test of the child to children and what I see is that when I hit next the page load breakpoint is hit and then the break point in the next button code and when it gets to that point the txtchildid.text is now empty. I made that text box visible so I could see the value in it and it does display the value I expect lets say 3 but in the next routine it shows ""

    There is a bit of code that has been added in those routines to try and get to the bottom of it but so far no difference.
    I do not do a lot of ASP.Net stuff, doing this one more as a favor for a friend but have hit a wall here. I am thinking that maybe this is happening because of the default run at server on the form code but am not sure nor am I sure what would be the best way to correct it if that is the case.

    Code:
    <form id="form1" runat="server">
    I edited the OP to show a break point location in each routine

  4. #4
    Hyperactive Member
    Join Date
    Nov 2017
    Posts
    323

    Re: Having issues with querystring when submitting data

    My best guess is that Page_Load is firing, neither of your If conditions are being met in Page_Load, Children is never being assigned a value, and therefore txtChildren.Text is being assigned nothing. One way to test this is to move the:

    Code:
    txtChildID.Text = Children
    line that you have at the end of Page_Load to the end of both of your If conditions.

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    12,295

    Re: Having issues with querystring when submitting data

    Page load fires and goes into the first condition where mode="Parent"

    I am rebuilding the form with out the run at server and asp controls on it, I expect it will be ok after doing that. Was hoping it was just a simple oversight on my part and would be a quick fix but am under the gun to get this working so time to move on and try to figure this issue out later so it doesn't happen again.

  6. #6
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    5,263

    Re: Having issues with querystring when submitting data

    Haven't have and extensive look as I am going out but try to use not page.ispostback
    Slow as hell.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width


×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.