Wednesday, March 28, 2012

Accessing Wizard controls from client-side Javascript

Hello, all. Thank you in advance for taking the time to read this. I know it is of questionable relevance given that the Wizard control is not an AJAX toolbox component, but since the Wizard is more useless without AJAX, I am hoping it is close enough to topic.

I am dealing with a Viewstate issue that is forcing me to use ScriptingServices for most of my async communications in order to keep round-trip bandwidth manageable. I want to be able to validate entries made on a long wizard both on-the-fly and at-once. But using ScriptServices, I need to access the values in the Wizard controls from client-side.

Trouble is, I have found that the wizard controls and their values are only visible to the DOM if the wizard page is active. Elements on non-active pages are totally inaccessible from client-side.

For example, a textbox with ID=TextBox1 is on page 1 of the wizard control ID=Wizard1; ID=TextBox2 is on page 2 of Wizard1

when Wizard1.ActiveStepIndex equates to page 1, then $get("TextBox1") works, but $get("TextBox2") does not.

I am assuming that there is some object reference to Wizard1 that can be used client-side to get the values from control on non-active pages, but I just can't seem to find it.

If anyone has experience with this and can tell me how to access these values, I would be highly appreciative.

Thank you again for the time, and in advance for any information you can provide.

Hi,

That's because only content of active step will be rendered. Though, all of them will be encoded and saved in ViewState.

My suggestion is use hiddenFields out of the wizard to keep the value of different steps, and they will be always generated and persisted.


Thanks again for your time and thoughts. That's exactly how I have decided to handle it. It sure adds a lot of complication to what seemed like a pretty easy control. Add to it that I am replacing long dropdown lists with static values after a selection has been made to trim the viewstate, and I think it would have been easier to start from scratch.

The hidden fields work great -- very good idea.

Thanks again!

No comments:

Post a Comment