• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

ASP .NET and IIS 6 problem

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    ASP .NET and IIS 6 problem

    I have a shopping basket system that's based on one written many a year ago in Perl. The initial link is something like:

    Basket.aspx?addtobasket=500

    where 500 refers to the product. The basket has up and down buttons, which call, for example

    Basket.aspx?incqty=500

    On VS2005 and whatever its test webserver is, this all works, and when I click on an up button it reloads the page increasing the quantity, and I notice that the URL in the browser address bar changes to the above.

    However uploaded to where it needs to go (a Windows 2003 IIS6 server), the up and down buttons don't work. If I click the down arrow, it reloads the page but the original "addtobasket" URL remains in the browser address bar and it carries out the addtobasket function rather than the increase/decrease.

    Can anyone shed any light on this? Maybe it's not the best approach, and I'm still feeling my way, but why does it not work consistently?
    Will work inside IR35. Or for food.

    #2
    Is this using the same browser or perhaps the one on the machine? I only mention that because win2k3 has some settings to disable javascript on sites which aren't trusted.

    Comment


      #3
      It's the server that's different. Same client machine and browser (and IE and Firefox do the same).
      Will work inside IR35. Or for food.

      Comment


        #4
        This may be a stupid question but you're not using server code behind to try to update the URL are you? If so, it won't work - your URL will always be a page behind.

        If you post the code, I'm sure someone will be able to help. I'll have a look myself later when I'm back on - that's if someone hasn't got back to you first, of course.

        Comment


          #5
          When you say 'up button' is this a server control running an onclick event like response.redirect/server.transfer or simply an image you've assigned a dynamic href="xxx" link to?

          If the former, make sure you aren't using server.transfer as this'll render your querystring shenanigans non-functional.

          If the latter then you should really be handling the quantity change within the click event (ideally asynchronously) rather than reading the querystring on postback page load.

          Edited, also check that the click isn't triggering a validator elsewhere on the page, i've had that happen before where an onclick event wont fire because the validation is failing on a form elsewhere. In that case set the 'CausesValidation' to false on the button.
          Last edited by Durbs; 1 March 2010, 18:40.

          Comment


            #6
            Originally posted by Durbs View Post
            If the former, make sure you aren't using server.transfer as this'll render your querystring shenanigans non-functional.
            WDurbsS. Response.redirect will work but will add an unnecessary server round-trip.

            Show us the code. We could be way off mark here.

            Comment


              #7
              It's an ASP table that I'm dynamically adding things to (I didn't know any other way), like this:

              Code:
              ImageButton img = new ImageButton();
              img.ImageUrl= "images/cartbuttons/increase_quantity.gif";
              img.Width = 20;
              img.Height = 14;
              img.BorderStyle = BorderStyle.None;
              c5.BackColor = Constants.clrBack;
              img.PostBackUrl = "Basket.aspx?addqty=y&item=" + basketID;
              c5.Controls.Add(img);
              (c5 is the TableCell).

              The quantities are stored in the DB, so surely it has to be handled by the server. But maybe I should be using an event rather than a PostBackURL?
              Will work inside IR35. Or for food.

              Comment


                #8
                PostBackUrl relies on javascript to change the form post action before submitting. It's a bizarre one given the facts presented so far but I would check...

                Do you get any javascript errors?
                Have you checked the page source especially around the html created for the imagebutton controls?
                Is "Basket.aspx?addqty=y&item=" + basketID evaluating to a string correctly?

                Comment


                  #9
                  It ends up like this, which is right as far as I can decypher it:

                  Code:
                  <input type="image" name="ctl04" src="images/cartbuttons/decrease_quantity.gif" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl04&quot;, &quot;&quot;, false, &quot;&quot;, &quot;Basket.aspx?decqty=y&amp;item=1&quot;, false, false))" style="border-style:None;height:14px;width:20px;border-width:0px;" />
                  I did a comparison of the code generated by the two webservers, and they're pretty much identical. Though one thing I did notice is that the action in the form is filled in.

                  I have in my aspx:

                  Code:
                   <form id="form1" runat="server" action="Basket.aspx">
                  The VS2005 server returns the same thing, whereas the IIS6 server adds the fields to the action. However taking out the action part meant they both returned all the fields, but still worked differently.

                  I have another asp:button on the page which has an OnClick handler, and that works properly. So maybe I just need to work out how to do that instead.

                  Could this be a caching thing? I tried setting the content expiration options on the server to immediate, but that hasn't affected anything.

                  Thanks for listening.
                  Will work inside IR35. Or for food.

                  Comment


                    #10
                    That is an odd problem Vectraman!

                    If you use "CommandName" and "CommandArgument" parameters for your image buttons, this will enable you to use the same event handler for your buttons and give you the ability to pass parameters.

                    Comment

                    Working...
                    X