Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Wizard Control Question

Wizard Control Question

Scheduled Pinned Locked Moved ASP.NET
questioncsharpcomgame-devhelp
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Brent Lamborn
    wrote on last edited by
    #1

    I've got a Wizard control on my page with 21 WizardSteps. Some of the steps contain ValidationGroups. Each step that needs validation has it's own ValidationGroup defined. Now what I need to do is dynamically set the ValidationGroup property for the Next and Previous buttons in my Wizard's StepNavigationTemplate. For some reason, my C# code behind does not "see" the buttons in my StepNavigationTemplate. For example, I want to code it this way: btnNext.ValidationGroup = "contactinfo"; The above does not work - a build time error occurs. I have also tried: Button btn = new Button(); btn = (Button)this.FindControl("ctl00_ContentPlaceHolder1_Wizard_StepNavigationTemplateContainerID_btnNext"); btnNext.ValidationGroup = "proofcontact"; as well as: Button btn = new Button(); btn = (Button)this.FindControl("btnNext"); btnNext.ValidationGroup = "proofcontact"; in each of the previous two above sets of code the familiar exception "Object not set to an instance..." occurs at runtime. Does anyone have a solution for this?


    "Half this game is ninety percent mental." - Yogi Berra If you can read thank a teacher, if you can read in English, thank a Marine.

    B 1 Reply Last reply
    0
    • B Brent Lamborn

      I've got a Wizard control on my page with 21 WizardSteps. Some of the steps contain ValidationGroups. Each step that needs validation has it's own ValidationGroup defined. Now what I need to do is dynamically set the ValidationGroup property for the Next and Previous buttons in my Wizard's StepNavigationTemplate. For some reason, my C# code behind does not "see" the buttons in my StepNavigationTemplate. For example, I want to code it this way: btnNext.ValidationGroup = "contactinfo"; The above does not work - a build time error occurs. I have also tried: Button btn = new Button(); btn = (Button)this.FindControl("ctl00_ContentPlaceHolder1_Wizard_StepNavigationTemplateContainerID_btnNext"); btnNext.ValidationGroup = "proofcontact"; as well as: Button btn = new Button(); btn = (Button)this.FindControl("btnNext"); btnNext.ValidationGroup = "proofcontact"; in each of the previous two above sets of code the familiar exception "Object not set to an instance..." occurs at runtime. Does anyone have a solution for this?


      "Half this game is ninety percent mental." - Yogi Berra If you can read thank a teacher, if you can read in English, thank a Marine.

      B Offline
      B Offline
      Brent Lamborn
      wrote on last edited by
      #2

      Ok, I found a solution though it's prbably not the best. I brute forced it into seaching the whole form for the correct control with this function: private Control FindIt(Control inCtrl, String ctrlEnd) { foreach (Control Ctrl in inCtrl.Controls) { if (Ctrl.ID == ctrlEnd) { return Ctrl; } else { if (Ctrl.HasControls()) { Control c = null; c = FindIt(Ctrl,ctrlEnd); if (!(c == null)) { return c; } } } } return null; } So I call it like this in the next button click event: if (Wizard.ActiveStepIndex == 16) { Button btn = new Button(); btn = (Button)FindMyControl(this, "btnNext"); if (!(btn == null)) { btn.ValidationGroup = "proofcontact"; } }


      "Half this game is ninety percent mental." - Yogi Berra If you can read thank a teacher, if you can read in English, thank a Marine.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups