Any way to prefill product template text field?

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
ZLA
Commodore (COMO)
Commodore (COMO)
Posts: 496
Joined: Fri Mar 13, 2009 2:55 pm

Any way to prefill product template text field?

Post by ZLA » Thu May 14, 2009 8:31 am

Has anyone ever prefilled a product template field with default text? I actually need to add an onblur event to the textbox but I figure if I can do one, I can get the other.

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Any way to prefill product template text field?

Post by mazhar » Thu May 14, 2009 9:22 am

Edit your App_Code/ProductHelper.cs class and locate BuildProductChoices(Product product, PlaceHolder phChoices) method change its

Code: Select all

if (o != null)
                    {
                        phChoices.Controls.Add(o);
                    }
to

Code: Select all


                    if (o != null)
                    {
                        if (o is TextBox)
                            o.Attributes.Add("onblur", "alert('Hello')");
                        phChoices.Controls.Add(o);
                    }

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Any way to prefill product template text field?

Post by mazhar » Thu May 14, 2009 9:30 am

For text you can cast object to TextBox, then set its text property.

ZLA
Commodore (COMO)
Commodore (COMO)
Posts: 496
Joined: Fri Mar 13, 2009 2:55 pm

Re: Any way to prefill product template text field?

Post by ZLA » Thu May 14, 2009 10:15 am

Could I also add an ASP.NET validation control this way? Adding the onblur would be for validation purposes but a validation control would be even better.

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Any way to prefill product template text field?

Post by mazhar » Fri May 15, 2009 2:21 am

Yes possible, read following thread
viewtopic.php?f=42&t=7154

ZLA
Commodore (COMO)
Commodore (COMO)
Posts: 496
Joined: Fri Mar 13, 2009 2:55 pm

Re: Any way to prefill product template text field?

Post by ZLA » Fri May 15, 2009 6:22 am

That will be perfect. I think I remember seeing that post at one time but had forgotten about it.

ZLA
Commodore (COMO)
Commodore (COMO)
Posts: 496
Joined: Fri Mar 13, 2009 2:55 pm

Re: Any way to prefill product template text field?

Post by ZLA » Sat May 16, 2009 12:13 am

I had another follow-up question. If I want the validator message to be specific to the individual product, should I just include a merchant field with that information in the product template?

Can you also explain to me if / how the various fields of a product template are identified so I can match up the merchant field with the customer fields of the product template?

Thank you.

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Any way to prefill product template text field?

Post by mazhar » Sat May 16, 2009 12:19 am

You can manipulate template.Input Fields and then search for some specific names. Secondly if you just want to put current product name for which you are handling input field then this information is directly available in this function through product object, you can make use of that as well.

Post Reply