I'm helping out on a web app and the developer that created the aspx pages is using <asp:wizard> on the form. There are dropdowns, labels, buttons, etc within each wizard.
How can I find a button in one of these wizards? I'm using something like
Button btn = (Button)Wizard.WizardStep[4].FindControl("button1");
btn.visible = false;
but I keep getting the error:
'Error: Object reference not set to an instance of an object'
how can find the button in the wizard so I can hide it?
Rob Meade - 24 Aug 2007 13:52 GMT
> how can find the button in the wizard so I can hide it?
If you run your app in debug mode can you stick a break point on the
page_load or event handler for that button, and then travese the properties
of the page/sender etc to see exactly what its called? The info contained
here might help you with the FindControl method.
HTH
Regards
Rob
Mike - 24 Aug 2007 14:02 GMT
i did that, I ran the page and did view source and got the actual control
name, and plugged that in the FindControl() and I still got the same error
message.
>> how can find the button in the wizard so I can hide it?
>
[quoted text clipped - 8 lines]
>
> Rob
clintonG - 26 Aug 2007 02:02 GMT
Enable trace in the page. You will be able to identify your button1 control
by reading through the control hierarchy. We must reuse the object name
hierarchy with the FindControl method. The use of the FindControl method
becomes somewhat convoluted when using MasterPages as you will often need to
use repetitive instances of the FindControl method in the same statement
which you will use to instantiate a btn object.

Signature
<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://clintongallagher.metromilwaukee.com/
I'm helping out on a web app and the developer that created the aspx pages
is using <asp:wizard> on the form. There are dropdowns, labels, buttons, etc
within each wizard.
How can I find a button in one of these wizards? I'm using something like
Button btn = (Button)Wizard.WizardStep[4].FindControl("button1");
btn.visible = false;
but I keep getting the error:
'Error: Object reference not set to an instance of an object'
how can find the button in the wizard so I can hide it?