Showing posts with label client-side. Show all posts
Showing posts with label client-side. Show all posts

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!

Accessing server-side Datatable object from client-side javascript?

I am working on a control that generates 2D charts (line,bar,pie,etc) using VML (for now) to draw the charts client-side. I am new to Javascript and still cant figure out how to access the data I need to graph from the javascript side. I am currently using a Sys.Data.Datable on the client side as test data (building the table manually in javascript) and it works fine but I cannot figure how to pass a datatable from the server to the control extension behavior?

I have read/seen code on the forums on how to do this using a web-service but I am really looking at a more generic approach where people could just bind a datatable to the control via the properties or in code so they can use their business logic layer functionality without having to write web-services.

Let's say I have the name of the page object/variable holding the datatable (from properties of control) how would I access this object as a Sys.Data.Datatable in Javascript? Would I need to use some kind of converter?

(hope I explained myself correctly and this makes sense to someone hehe)

Thanks in Advance

Pascal

Hello Pascal:

> I am new to Javascript and still cant figure out how to access the data I need to graph from the javascript side.

Strictly speaking, you can't! It is the server-side code that renders client-side code, so what you can do is actually the reverse: write the datatable to javascript.

Here is a topic that can give some hints:http://forums.asp.net/thread/1285185.aspx

This said, please feel free to go deeper with your question if needed.

-LV


Thanks for the quick reply btw :)

Here is some example of what I am trying to do (not actual code):

Lets say I have some ASPX page code like...

<script language="VB"> Private sub Page_Load() dim myTable as System.Data.Datatable ... populate table ... End sub</script><html> <body> <atlas:ScriptManager runat="server" ID="PageScriptManager" EnablePartialRendering="True"> </atlas:ScriptManager> <asp:Panel ID="ChartPanel" runat="server" Height="300" Width="400" /> <cc1:ChartPanelExtender ID="ChartPanelExtender1" runat="server" > <cc1:ChartPanelProperties ChartTitle="This is my Graph!" TargetControlID="ChartPanel" ChartType="0" ChartHeight="100" ChartWidth="300" ChartBackColor="#FF3A00" ChartTitleFontFamily="Arial Black" ChartTitleFontSize="20" ChartTitleFontWeight="Normal" ChartTitleTextAlign="Right" /> </cc1:ChartPanelExtender> </body></html>

The ChartPanelExtender is an atlas control extender that has its functionality (chart graphing) in its ChartPanelBehavior.js javascript file. What I would like to do is access that myTable from inside the javascript behavior file? Is that possible?

Thanks in advance,

Pascal

Accessing PopupControl methods from client script

Hi,

How can I access the client-side functions of the PopupControl (namely "hide()")? Rather than the user having to click elsewhere on the page I also want to have a close button. According to the Firebug DOM explorer, the div element thats used for the popup has a property "PopupBehaviour" but trying to access this throws an error.

Cheers

Hi,

Not sure if this is the "correct" way to do this but I do this:

ButtonClose.Attributes.Add("OnClick","__AjaxControlToolkit_PopupControlBehavior_VisiblePopup.hidePopup();");

HTH

Jeff


I'm running into the same problem. I want to do a client-side close of the popupcontrol. I tried getting the uniqueid of the panel that's being popped up and setting the .style.display property to 'none' and that closes the panel but the problem is that whatever controls the panel used to cover are disabled. They've done this on purpose to disable controls from underneath the overlayed panel from being selected while you are selecting controls on the panel. So my solution half works.

Does anyone in the ASP team or someone who's had a need to close the popupcontrol control on the client-side have a clean a proper solution for this? Doing a postback to close the extender is a really stupid way of closing it so I'm sure someone must have come across this... Thanks!


Hi,

In version 1.0.10123.0 of the toolkit i do this on the client side which seems to work, as I said before I'm not sure if this is the correct way but it works.

AjaxControlToolkit.PopupControlBehavior.__VisiblePopup.hidePopup();
hth
Jeff 

I found this nice free popupcontrol. It comes with full source and also the .dll. Its nice to have this control in your Visual Studio Toolbox. ;)

Dainty Date


Jeff, thanks that works.


Cool. I will try that. Currently I use a button that calls "document.body.click()" to simulate the clicking elsewhere outside of the popup which effectively closes it.

Hi,

The easeist way to do this is add a BehaviorID="MyPopup" on the extender and then usevar behavior = $find('MyPopup'); in script.

Thanks,
Ted