Page 1 of 1
Any way to prefill product template text field?
Posted: Thu May 14, 2009 8:31 am
by ZLA
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.
Re: Any way to prefill product template text field?
Posted: Thu May 14, 2009 9:22 am
by mazhar
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);
}
Re: Any way to prefill product template text field?
Posted: Thu May 14, 2009 9:30 am
by mazhar
For text you can cast object to TextBox, then set its text property.
Re: Any way to prefill product template text field?
Posted: Thu May 14, 2009 10:15 am
by ZLA
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.
Re: Any way to prefill product template text field?
Posted: Fri May 15, 2009 2:21 am
by mazhar
Yes possible, read following thread
viewtopic.php?f=42&t=7154
Re: Any way to prefill product template text field?
Posted: Fri May 15, 2009 6:22 am
by ZLA
That will be perfect. I think I remember seeing that post at one time but had forgotten about it.
Re: Any way to prefill product template text field?
Posted: Sat May 16, 2009 12:13 am
by ZLA
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.
Re: Any way to prefill product template text field?
Posted: Sat May 16, 2009 12:19 am
by mazhar
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.