Page 2 of 3

Re: Shipping Drop Down to Radio List

Posted: Fri Oct 17, 2008 9:33 am
by draneb
Oh, I am not sure as I haven't submitted a test order yet, but I just liked the countdown box that is used on the multiple shipments page where it starts at 255 and counts down as you type in characters.

Re: Shipping Drop Down to Radio List

Posted: Fri Oct 17, 2008 10:08 am
by AbleMods
draneb wrote:Oh, I am not sure as I haven't submitted a test order yet, but I just liked the countdown box that is used on the multiple shipments page where it starts at 255 and counts down as you type in characters.
Oh ok. I'm not sure how that would be done. Sounds like a task for Javascript since it would need to be client-side. Unfortunately I have no clue on Javascript, but there are others in the forums who are great at it.

Re: Shipping Drop Down to Radio List

Posted: Fri Oct 17, 2008 10:52 am
by mazhar
Well guys for this tip I think i deserve a Pepsi. :wink:
This is very easy job in AbleCommerce. Each and every thing is already done you just need to use it. You can create your own countown box in approximately in 5mnts of less. For example create a CountBox.ascx file in the ConLib and then put following code in it

Code: Select all

<%@ Control Language="C#" AutoEventWireup="true"%>
<script runat="server" >
    protected void Page_Load(object sender, EventArgs e)
    {
        CharCount.Text = ((int)(CountBox.MaxLength - CountBox.Text.Length)).ToString();
        PageHelper.SetMaxLengthCountDown(CountBox, CharCount);
    }
</script>
<asp:TextBox ID="CountBox" runat="Server" Text="" Rows="5" TextMode="MultiLine" Width="100%" MaxLength="255" />
<asp:Label ID="CharCount" runat="server" Text="250"></asp:Label>
<asp:Localize ID="CharCountLabel" runat="server" Text="characters remaining"></asp:Localize>

That's all. Now you can use it on store side. Its just a sample the basic thing is that you can create count down boxes any where in your pages like this one.

Re: Shipping Drop Down to Radio List

Posted: Fri Oct 17, 2008 11:10 am
by draneb
Mazhar,

I'll ship you a 12 pack of anything you want. Thank you! I am still having trouble though :(

It works great as a ConLib plugin on pages but could you briefly explain how to implement the code into the OnePageCheckout file(s)? You can't really put it after the [[ConLib:OnePageCheckout]] tag because there are other elements such as Payment Method and Order Contents so the CountBox is shown at the very bottom of the page after the Payment button.

Code: Select all

<%@ Control Language="C#" AutoEventWireup="true"%>
<script runat="server" >
protected void Page_Load(object sender, EventArgs e)
{
CharCount.Text = ((int)(CountBox.MaxLength - CountBox.Text.Length)).ToString();
PageHelper.SetMaxLengthCountDown(CountBox, CharCount);
}
</script>
<asp:TextBox ID="CountBox" runat="Server" Text="" Rows="4" TextMode="MultiLine" Width="100%" MaxLength="255" />
<asp:Label ID="CharCount" runat="server" Text="255"></asp:Label>
<asp:Localize ID="CharCountLabel" runat="server" Text="characters remaining"></asp:Localize>
I tried splitting the code and putting the CountBox portion in the OnePageCheckout.ascx file and the <script> to </script> code in the OnePageCheckout.ascx.cs file and I get an error. I tried putting all of the code (less the first line which is already there) in the OnePageCheckout.ascx file and still get an error.

I'm going to go shopping for a book to read because I want to be able to do things like this myself instead of troubling you guys.

Thank you.

Re: Shipping Drop Down to Radio List

Posted: Sat Oct 18, 2008 6:42 am
by mazhar
I have created the ConLib just for the sample. If you want to use it on some page like onepage checkout first you need to prepare the text box. For example if the control name is MyTextBox as below

Code: Select all

<asp:TextBox ID="MyTextBox" runat="Server" Text="" Rows="4" TextMode="MultiLine" Width="100%" MaxLength="255" />
Then first you need to add following two labels just below it and name them as you wish

Code: Select all

<asp:Label ID="MyTextBoxCharCount" runat="server" Text="255"></asp:Label>
<asp:Localize ID="MyTextBoxCharCountLabel" runat="server" Text="characters remaining"></asp:Localize>
Then all you need to is to add following two lines of code in the page_load function of the page

Code: Select all

MyTextBoxCharCount.Text = ((int)(MyTextBox.MaxLength - MyTextBox.Text.Length)).ToString();
PageHelper.SetMaxLengthCountDown(MyTextBox, MyTextBoxCharCount);
A good example of this is the Admin/EditProduct.aspx Page. For example check the Summary text box.

Re: Shipping Drop Down to Radio List

Posted: Sat Oct 18, 2008 7:17 am
by AbleMods
draneb wrote:I'm going to go shopping for a book to read because I want to be able to do things like this myself instead of troubling you guys.
Now you know why I rarely post full code solutions to a forum member request. Give a man a fish and you feed him for a day. Teach a man to fish and you've fed him for life. :wink:

Would you believe a year ago I walked out of the store with "ASP.Net for Dummies" sheepishly tucked under my arm? Some of it is incredibly basic but it's a good start if you've got no programming background.

From there, look for "Beginning ASP.Net 2.0" by Wrox. Big book, lots of examples and bright red cover so you can't miss it on the shelf. It walks you through a complete application development - see the final result of what you will create at http://www.wroxunited.net. I must have had 12 post-it notes sticking it out of that book at one point :)

Those two books gave me a great start on the path that led me to where I am today. I had ALOT of previous programming experience, but all of this .NET, HTML and "data classes" thing was completely foreign to me.

You have not been "troubling" the forum members. We enjoy helping whenever we can. Most of us feel by helping others, we also help ourselves. Every person that crosses our path, be they online or otherwise, is an opportunity to learn.

Now, about Mazhar horning in on my Pepsi...... :P

Re: Shipping Drop Down to Radio List

Posted: Sat Oct 18, 2008 7:31 am
by jmestep
Now I know what my problem is. I bought the wrong book and I like Dr. Pepper instead of Pepsi!

Re: Shipping Drop Down to Radio List

Posted: Sat Oct 18, 2008 7:43 am
by draneb
I don't like the way caffeine makes me feel so I stopped drinking it over 10 years ago but recently picked up a gallon jug of iced tea because I'm trying to stay away to figure this out.

OMG, of course, the Dummies book. Wow they really do make that book for everything. I'm definitely going to get that today.

Okay I am going to post my code in one last valiant attempt. I am still getting an error and it has to be something simple.
Maybe up at the top of the pages do I need to change any of that to Custom_OnePageCheckout? At the top of the page I have this

Code: Select all

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="OnePageCheckout.ascx.cs" Inherits="ConLib_OnePageCheckout" %>
But I do have the pages in the ConLib/Custom folder now.

OnePageCheckout.ascx.cs page looks like this

Code: Select all

CountBoxCharCount.Text = ((int)(CountBox.MaxLength - CountBox.Text.Length)).ToString();
        PageHelper.SetMaxLengthCountDown(CountBox, CountBoxCharCount);
    }
and on OnePageCheckout.ascx page I have this

Code: Select all

<asp:Label ID="ShipMessageCaption" runat="server" Text="Special Instructions/Comments/Deadlines:" SkinID="FieldHeader"></asp:Label><br />
    <asp:TextBox ID="CountBox" runat="Server" Text="" Rows="4" TextMode="MultiLine" Columns="28" MaxLength="255" />
    <asp:Label ID="CharCount" runat="server" Text="255"></asp:Label>
    <asp:Localize ID="CharCountLabel" runat="server" Text=" characters remaining"></asp:Localize>
and it's giving me this error: ConLib\Custom\OnePageCheckout.ascx.cs(1465): error CS0116: A namespace does not directly contain members such as fields or methods

This is enough to make you want to pull your hair out. ha

Re: Shipping Drop Down to Radio List

Posted: Sat Oct 18, 2008 8:29 am
by mazhar
its here this statement

Code: Select all

PageHelper.SetMaxLengthCountDown(CountBox, CountBoxCharCount);
change the CountBoxCharCount to CharCount like

Code: Select all

PageHelper.SetMaxLengthCountDown(CountBox, CharCount);

Re: Shipping Drop Down to Radio List

Posted: Sat Oct 18, 2008 11:05 am
by draneb
One last time before I give up. I hate being a quitter.

Here is the latest code I tried.. I am even using the same names as Mazhar used.
I am now getting a different error.
ConLib\Custom\OnePageCheckout.ascx.cs(322): error CS1519: Invalid token '=' in class, struct, or interface member declaration

Can you notice anything wrong with this?
In the .ascx.cs file:

Code: Select all

protected void Page_Load(object sender, EventArgs e)
    {
        if (CheckoutPanel.Visible)
            {
                //SHIPPING ADDRESS HAS CHANGED, INITIALIZE NOW
                //TO OVERRIDE POSTED BACK VALUES
                if (_NewShippingAddress != null)
                    InitializeShippingAddressForm(_NewShippingAddress, true);

                if (!Page.IsPostBack)
                {
                    InitializeBasket();
                }
                //AbleMods: Begin MOD
                // 10-16-08
                else if (Request.Form["__EVENTTARGET"].Contains("ShipMethodList"))
                //AbleMods: END Mod
                {
                    //RECALCULATE ORDER USING SELECTED SHIPPING METHODS
                    //ONLY DO THIS IF THE SHIPPING METHOD LIST HAS CHANGED
                    //ALSO REBIND THE PAYMENT FORMS
                    RecalculateBasket(true);
                    ValidateShipStatus(false);
                }
            }
    }
                    //COUNTDOWN CHARACTER TEXTBOX
                    MyTextBoxCharCount.Text = ((int)(MyTextBox.MaxLength - MyTextBox.Text.Length)).ToString();
                    PageHelper.SetMaxLengthCountDown(MyTextBox, MyTextBoxCharCount);
}
then in .ascx file

Code: Select all

<asp:Label ID="ShipMessageCaption" runat="server" Text="Special Instructions/Comments/Deadlines:" SkinID="FieldHeader"></asp:Label><br />
<asp:TextBox ID="MyTextBox" runat="Server" Text="" Rows="4" TextMode="MultiLine" Width="255" MaxLength="255" />
<asp:Label ID="MyTextBoxCharCount" runat="server" Text="255"></asp:Label>
<asp:Localize ID="MyTextBoxCharCountLabel" runat="server" Text=" characters remaining"></asp:Localize>
Thank you!

Re: Shipping Drop Down to Radio List

Posted: Sat Oct 18, 2008 2:24 pm
by afm
There is an extra closing brace (}). Probably at line 320 or so (I'm guess that line 322 shown in the error message is the line that starts "MyTextBoxCharCount.Text = ").

Re: Shipping Drop Down to Radio List

Posted: Mon Oct 20, 2008 8:27 am
by mazhar
Problem Seems to be here
}
//COUNTDOWN CHARACTER TEXTBOX
MyTextBoxCharCount.Text = ((int)(MyTextBox.MaxLength - MyTextBox.Text.Length)).ToString();
PageHelper.SetMaxLengthCountDown(MyTextBox, MyTextBoxCharCount);
}
Remove the very last curly brace and then move the countdown code one step above so that it should look like

Code: Select all

protected void Page_Load(object sender, EventArgs e)
    {
        if (CheckoutPanel.Visible)
            {
                //SHIPPING ADDRESS HAS CHANGED, INITIALIZE NOW
                //TO OVERRIDE POSTED BACK VALUES
                if (_NewShippingAddress != null)
                    InitializeShippingAddressForm(_NewShippingAddress, true);

                if (!Page.IsPostBack)
                {
                    InitializeBasket();
                }
                //AbleMods: Begin MOD
                // 10-16-08
                else if (Request.Form["__EVENTTARGET"].Contains("ShipMethodList"))
                //AbleMods: END Mod
                {
                    //RECALCULATE ORDER USING SELECTED SHIPPING METHODS
                    //ONLY DO THIS IF THE SHIPPING METHOD LIST HAS CHANGED
                    //ALSO REBIND THE PAYMENT FORMS
                    RecalculateBasket(true);
                    ValidateShipStatus(false);
                }
            }
                    //COUNTDOWN CHARACTER TEXTBOX
                    MyTextBoxCharCount.Text = ((int)(MyTextBox.MaxLength - MyTextBox.Text.Length)).ToString();
                    PageHelper.SetMaxLengthCountDown(MyTextBox, MyTextBoxCharCount);
    }



Re: Shipping Drop Down to Radio List

Posted: Mon Oct 20, 2008 9:22 am
by draneb
Hello Mazhar,

I did exactly as you said and now it gives this error message.

ConLib\Custom\OnePageCheckout.ascx.cs(321): error CS0103: The name 'MyTextBoxCharCount' does not exist in the current context

This is the craziest thing ever. What does that mean?

Re: Shipping Drop Down to Radio List

Posted: Mon Oct 20, 2008 9:38 am
by mazhar
Revert all your countbox related changes from OnePageCheckout control.
First edit the OnePageCheckout.ascx file and locate the following code

Code: Select all

<tr id="trContinue" runat="server" enableviewstate="false">
and put the following code just above so that it should look like

Code: Select all

<tr>
                            <td>
                             
            <asp:Label ID="ShipMessageCaption" runat="server" Text="Special Instructions/Comments/Deadlines:" SkinID="FieldHeader"></asp:Label><br />
<asp:TextBox ID="MyTextBox" runat="Server" Text="" Rows="4" TextMode="MultiLine" Width="255" MaxLength="255" />
<asp:Label ID="MyTextBoxCharCount" runat="server" Text="255"></asp:Label>
<asp:Localize ID="MyTextBoxCharCountLabel" runat="server" Text=" characters remaining"></asp:Localize>
            
                            </td>
                            </tr>
<tr id="trContinue" runat="server" enableviewstate="false">
Now edit the OnePageCheckout.ascx.cs file and locate the Page_Load method and make it look like

Code: Select all

protected void Page_Load(object sender, EventArgs e)
    {
        if (CheckoutPanel.Visible)
        {
            //SHIPPING ADDRESS HAS CHANGED, INITIALIZE NOW
            //TO OVERRIDE POSTED BACK VALUES
            if (_NewShippingAddress != null)
                InitializeShippingAddressForm(_NewShippingAddress, true);

            if (!Page.IsPostBack)
            {
                InitializeBasket();
            }
            else if (Request.Form["__EVENTTARGET"].EndsWith("ShipMethodList"))
            {
                //RECALCULATE ORDER USING SELECTED SHIPPING METHODS
                //ONLY DO THIS IF THE SHIPPING METHOD LIST HAS CHANGED
                //ALSO REBIND THE PAYMENT FORMS
                RecalculateBasket(true);
				ValidateShipStatus(false);
            }
        }
        //COUNTDOWN CHARACTER TEXTBOX
        MyTextBoxCharCount.Text = ((int)(MyTextBox.MaxLength - MyTextBox.Text.Length)).ToString();
        PageHelper.SetMaxLengthCountDown(MyTextBox, MyTextBoxCharCount);
    }

Re: Shipping Drop Down to Radio List

Posted: Mon Oct 20, 2008 11:22 am
by draneb
Whoo hoooo! Thanks Mazhar, that worked... I am going to go have an O'Doul's now and celebrate.

Re: Shipping Drop Down to Radio List

Posted: Mon Oct 20, 2008 11:35 am
by AbleMods
draneb wrote:Whoo hoooo! Thanks Mazhar, that worked... I am going to go have an O'Doul's now and celebrate.
Real men drink Pepsi :P

Re: Shipping Drop Down to Radio List

Posted: Mon Oct 20, 2008 5:02 pm
by draneb
Hey I have a 6 pack of caffeine free Pepsi chillin in the fridge.

So, I received my book this afternoon on how to program in asp.net 2.0 with AJAX. I read through it in 24 minutes and thanks to my new skills I was able to find an issue in the checkout process.

Yes, on the OnePageCheckout page if you leave your phone number blank and try submitting the order it will say

  • Phone number number is required.
(number is mentioned twice)

I am so glad I bought this book. :lol:

Re: Shipping Drop Down to Radio List

Posted: Mon Oct 20, 2008 8:50 pm
by Robbie@FireFold
We bought the book Beginning ASP.Net 2.0 per Joe's suggestion.

William(Gray) and Evan will have some reading to do. :mrgreen:

Re: Shipping Drop Down to Radio List

Posted: Mon Oct 20, 2008 10:59 pm
by AbleMods
Robbie@FireFold wrote:We bought the book Beginning ASP.Net 2.0 per Joe's suggestion.

William(Gray) and Evan will have some reading to do. :mrgreen:

Awww comon, I got a car payment too you know :wink:

Re: Shipping Drop Down to Radio List

Posted: Fri Nov 20, 2009 3:55 pm
by AbleMods
* UPDATE *

Attached are updated files for version 7.0.3 of AbleCommerce OnePageCheckout. Now your checkout page shipping methods will render as radio buttons instead of a dropdown list and they'll be sorted in order of cheapest to most expensive.

Enjoy!

Re: Shipping Drop Down to Radio List

Posted: Fri Nov 20, 2009 7:00 pm
by compunerdy
What changed? Your old code still worked for 7.0.3 I thought or maybe I adjusted it.

Re: Shipping Drop Down to Radio List

Posted: Fri Nov 20, 2009 7:56 pm
by AbleMods
This is one of those mods where I posted the full modified files instead of just the steps to make the changes. The old file in the zip was a previous version of OnePageCheckout from an older AC7 version. I wasn't entirely sure it would work in 7.0.3 given all the changes, so I adapted them to the 7.0.3 checkout for everyones benefit.

Re: Shipping Drop Down to Radio List

Posted: Sat Nov 21, 2009 10:45 am
by compunerdy
True.. I probably used file compare and merged your changes as well.

You know..7.0.3 has been out for over 5 months. What took you so long? :mrgreen:

Re: Shipping Drop Down to Radio List

Posted: Sat Nov 21, 2009 11:17 am
by AbleMods
LOL me forgots to merge that one into my 7.0.3 :D

Re: Shipping Drop Down to Radio List

Posted: Tue Aug 10, 2010 6:17 pm
by AbleMods
Update: Attached is an AC 7.0.5 version of OnePageCheckout that includes this modification. Enjoy !