Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Martin Lingstuyl 202 posts 379 karma points
    Aug 20, 2012 @ 18:26
    Martin Lingstuyl
    0

    Refreshing Multi-step form with Custom Fieldtype/Control generates error

    Hi guys,

    hope someone can help me with this problem.

    I'm having a custom Fieldtype (basically a textbox with some extra stuff) enabling visitors to select a person from a list of persons. After this they click next and in the next form step they fill in some information.

    Now when I select a person from the list, click next and then Refresh the page I get an error referring to my custom Control.

    System.Web.HttpException: Unable to find control id 
    'RelatieVraagTherapeutId' referenced by the 'ControlToValidate' property
     of 'mandatory'. 
    Generated: Mon, 20 Aug 2012 16:11:07 GMT System.Web.
    HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.Web.HttpException (0x80004005): Unable to find control id 'RelatieVraagTherapeutId' referenced by the 'ControlToValidate' property of 'mandatory'. at System.Web.UI.WebControls.BaseValidator.CheckControlValidationProperty(String name, String propertyName) at System.Web.UI.WebControls.BaseValidator.ControlPropertiesValid() at System.Web.UI.WebControls.BaseValidator.Validate() at System.Web.UI.Page.Validate(String validationGroup) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
    ... etc

     

    The control ID 'RelatieVraagTherapeutId' did not match the clientID from the textbox. so I gave the custom Fieldtype a static ID 'RelatieVraagTherapeutId'. But still ... the same error appears.

    Anyone have experience with this?

    Martin

  • Martin Lingstuyl 202 posts 379 karma points
    Aug 20, 2012 @ 18:28
    Martin Lingstuyl
    0

    btw: I'm using Umbraco 4.7.2 and Contour. 1.1.13

  • Comment author was deleted

    Aug 21, 2012 @ 12:47

    Hey Martin,

    Could you share the code for the custom fieldtype ?

  • Martin Lingstuyl 202 posts 379 karma points
    Aug 21, 2012 @ 14:04
    Martin Lingstuyl
    0

    Hi Tim,

    Thanks for responding so fast!

    This is the Code for the Custom Fieldtype:

     

    public class PCListMembers : FieldType
    {
    public CustomControls.PCListOfTherapists lt = new CustomControls.PCListOfTherapists();


    public PCListMembers()
    {
    //Provider
    this.Name = "Filterlijst Postcode/Afstand";
    this.Description = "Filterlijst waarin een therapeut geselecteerd kan worden.";
    this.Id = new Guid("aaa47ea9-2a78-4524-b9d6-6dfaeab39c31");

    //FieldType
    this.Icon = "dropdownlist.png";
    this.DataType = FieldDataType.Integer;
    }


    public List<Object> _value = new List<object>();
    public override List<object> Values
    {
    get
    {
    if (lt.Text != "")
    {
    _value.Clear();
    _value.Add(lt.Text);
    }
    return _value;
    }
    set
    {
    _value = value;
    }
    }

    public override WebControl Editor
    {
    get
    {
    if (_value.Count > 0)
    {
    lt.Text = _value[0].ToString();
    }

    return lt;
    }
    set
    {
    base.Editor = value;
    }
    }

    public override string RenderPreview()
    {
    return "<input type=\"text\" class=\"textfield\" />";
    }

    public override string RenderPreviewWithPrevalues(List<object> prevalues)
    {
    return RenderPreview();
    }

    public override bool SupportsRegex
    {
    get
    {
    return true;
    }
    }
    }
  • Martin Lingstuyl 202 posts 379 karma points
    Aug 21, 2012 @ 14:06
    Martin Lingstuyl
    0

    And this is the code for the custom Control that's referenced:

     


    public class PCListOfTherapists : TextBox
    {
    public override void RenderControl(HtmlTextWriter writer)
    {


    writer.Write("<div class='filterControl'>");
    writer.Write("<div class='filterBox'><div class='zoekLeftLong'><p>Voer postcode in:</p></div><div class='zoekInput'><input type='text' class='textbox pc_" + GetID() + "' id='filterpc" + GetID() + "' name='filterpc' class='textbox kmtb' title='VB:3300AA' value='VB:3300AA'/></div>");
    //writer.Write("<div class='zoekLeft'><p>Km:</p></div><div class='zoekInput'><input type='text' class='textbox km_" + GetID() + "' id='filterkm' name='filterkm' class='textbox' style='display:none;' title='VB:10(km)' value='VB:10(km)'/></div>");
    writer.Write("<div class='zoekBtnShort'><input type='button' id='submitpc' value='' title='" + CommunityModules.EditDictionaryItem.GetDictionaryItem("[Template] Zoeken Refresh", "Klik om de therapeutenlijst te verversen") + "' class='subm_" + GetID() + " buttonRefresh'/></div><div class='SpinnerWrapper' style='display:none;'><img src='/images/loading2.gif' alt='Loading...' /></div></div>");
    writer.Write("<div class='filterContainer'><div class='filterWrapper'><div class='filterList pclist'><div class='filterPieContainer'><ul class='filterlistUl'><li><i>Voer postcode in om therapeuten te zoeken.</i></li></ul></div></div></div><br style='clear:both;'/><hr/><p><strong>Geselecteerd</strong>: <span id='selnames'><i>Geen</i></span></p></div>");
    base.RenderControl(writer);
    writer.Write("</div>");
    }


    protected override void OnInit(EventArgs e)
    {
    base.OnInit(e);
    this.TextMode = TextBoxMode.SingleLine;
    this.CssClass = "text RelatieVraagTherapeutIdCl LOT_" + GetID();
    this.Attributes.Add("style", "display:none;");

    this.ID = "RelatieVraagTherapeutId";
    this.ClientIDMode = ClientIDMode.Static;




    string script = "$(document).ready(function() {";

    //SOME AJAX SCRIPT....

    umbraco.library.RegisterClientScriptBlock("FilterMethod", script, true);


    }

    private string GetID()
    {
    return "LOT_RelatieVraagTherapeutIdCl";
    }


    public string Value
    {
    get
    {

    return this.Text;

    }
    set
    {
    this.Text = value;
    }

    }

    }
  • Martin Lingstuyl 202 posts 379 karma points
    Aug 21, 2012 @ 14:07
    Martin Lingstuyl
    0

    So what it does is Call an ajax method which loads a list of members dynamically and inserts them in some nice way in a scrolled div.

    Then if you click on one of the members, the memberid is getting saved in a hidden TextBox, the value of which gets saved in the contour form.

     

  • Comment author was deleted

    Aug 21, 2012 @ 14:09

    Could you try moving the lt =newCustomControls.PCListOfTherapists(); into the constructor ?

  • Comment author was deleted

    Aug 21, 2012 @ 14:10

    + remove 

    this.ID ="RelatieVraagTherapeutId";
    this.ClientIDMode=ClientIDMode.Static;
  • Martin Lingstuyl 202 posts 379 karma points
    Aug 21, 2012 @ 14:59
    Martin Lingstuyl
    0

    Hi Tim,

     

    Did that both. Still the same error when hitting F5 on step 2. Little different now:

    Unable to find control id '4a8e7678_932e_4c3d_8d77_39bb02272ceb' referenced by the 'ControlToValidate' property of 'mandatory'.

    But that's just the Control ID. (although the control ClientID is ContentPlaceHolderDefault_ctl06_RenderForm_1_rpFieldsets_rpFields_0_4a8e7678_932e_4c3d_8d77_39bb02272ceb_0 )

     

     

  • Martin Lingstuyl 202 posts 379 karma points
    Sep 04, 2012 @ 17:26
    Martin Lingstuyl
    0

    Hi Tim,

    Could you look into this again? It's happening with all my forms with custom Field Types.(I've constructed several)

    hope to hear from you!

     

    Martin

  • Martin Lingstuyl 202 posts 379 karma points
    Oct 05, 2012 @ 09:57
    Martin Lingstuyl
    0

    Hi Tim,

    You havent responded yet. Probably lots of things on your agenda.

    Anyways, I'd love to know at least if its still on your radar and whether you could plan in some time. (even if it's in a few weeks I'd be greatful)

    thanks in advance.

    Martin

  • Martin Lingstuyl 202 posts 379 karma points
    Oct 12, 2012 @ 16:31
    Martin Lingstuyl
    0

    Ok, I now think it isn't the custom Fieldtype after all, because I'm having similar issues on other forms.

    And other users seem to experience these too: http://our.umbraco.org/forum/umbraco-pro/contour/28594-Contour-form-steps

     

    So, I don't know what's wrong. But it's pretty weird behavior. Anybody got a workaround?

     

    Martin

Please Sign in or register to post replies

Write your reply to:

Draft