Tech Off Thread

9 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

WizardControl Form-Submission Problem

Back to Forum: Tech Off
  • User profile image
    jsampsonPC

    I have a wizard control with many steps in it. When the user selects a form element inside one of the steps, the WizardControl Previous Button gets selected, so that whenever you press Enter, the form is posted back to the previous wizardControl, and not the next-up one.

    I looked for a "Default Button" value on the control, but cannot find one - how can I change this action to make the "Next" button the Default WizardControl button?

  • User profile image
    jsampsonPC

    Door.KnockKnock();

  • User profile image
    phreaks

    I don't think you can. If those are your requirements, perhaps you should roll your own control that includes that functionality.

    I don't believe The Wizard exposes the buttons (which doesn't make much sense to me).

    You can try this, but I am not sure it will work, but certainly worth a try.

    protected void Wizard1_Load(object sender, EventArgs e)
    {
       SetNextButton(this.Wizard1);
    }


    public void SetNextButton(Control myControl)
    {

    String clientID;
    String controlType;
    String controlID;

    //System.Text.StringBuilder sb = new System.Text.StringBuilder();

    foreach (Control ctrl in myControl.Controls)
    {

       clientID = ctrl.ClientID;
       controlType = ctrl.GetType().ToString();
       controlID = ctrl.ID;

       if (ctrl is Button)
       {
             /*
             sb.AppendFormat("ClientID: {0} <BR> Type: {1}<BR>ID: {2}<BR>", clientID, controlType, controlID);
             Response.Write(sb.ToString() + "<BR/>");
          sb.Remove(0, sb.Length);
          */

          if(ctrl.ClientID.Contains("Next"))
          {
             Page.RegisterHiddenField("__EVENTTARGET", controlID);
          }
       }

       if (ctrl.HasControls())
       {
          SetNextButton(ctrl);
       }

    }

    }


    //EDIT: this prolly isn't going to work .
    Uncomment my edited comments and it will give you the info on all your wizard buttons. Maybe it will help. I would just write my own control instead of using the wizard.

  • User profile image
    jsampsonPC

    I've already spent 21 days developing this app with a WizardControl, and today is deployment day - so I can't write my own control now.

    It seems bizarre that this control would ship without letting the user decide which button (Previous / Next) would be the default form-submission button.

    It seems even more ridiculous that each step would default to "Previous", and not "Next".

    Surely somebody else has come to this problem before?

  • User profile image
    jsampsonPC

    Page.RegisterHiddenField isn't showing up in VB - is this deprecated?

  • User profile image
    phreaks

    jsampsonPC wrote:
    Page.RegisterHiddenField isn't showing up in VB - is this deprecated?


    Yeah, but should still work.

    ClientScript.RegisterHiddenField is the new method in 2.0

  • User profile image
    jsampsonPC

    phreaks wrote:
    
    jsampsonPC wrote:Page.RegisterHiddenField isn't showing up in VB - is this deprecated?


    Yeah, but should still work.

    ClientScript.RegisterHiddenField is the new method in 2.0


    Yeah, I found it shortly after I posted the question. Unfortunately, it still isn't working...

    I wish somebody from the ASP.NET team would weigh-in on this Smiley

  • User profile image
    phreaks

    jsampsonPC wrote:
    
    phreaks wrote: 
    jsampsonPC wrote: Page.RegisterHiddenField isn't showing up in VB - is this deprecated?


    Yeah, but should still work.

    ClientScript.RegisterHiddenField is the new method in 2.0


    Yeah, I found it shortly after I posted the question. Unfortunately, it still isn't working...

    I wish somebody from the ASP.NET team would weigh-in on this Smiley


    If you have multiple "next" steps, it prolly isn't going to work, as it will try to register them all.

    The trick I am guessing, would be to somehow determine which Step you are on and find the Next button for that step only, and then try to register it as the default.

    I haven't done much web work in a few years, so I am prolly not the best resource; but in the absence of any other replies thought it was worth a shot.

  • User profile image
    jsampsonPC

    I'll play with it more later - I'm sure there are several possible solutions. For now, I'm going with this:

        Protected Sub app_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles app.Load

            For Each ws As WizardStep In app.WizardSteps
                ws.AllowReturn = False
            Next

        End Sub

    I'll just do without the previous buttons for now Smiley

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.