Showing posts with label behavior. Show all posts
Showing posts with label behavior. Show all posts

Wednesday, March 28, 2012

Change in behavior of RegisterStartupScript

In Beta 1, it is requried to use the ScriptManager.RegisterStartupScript method, and this method requires that a control that is within the partial update is passed as the first parameter.

All my pages inherit the same BasePage, and I wan't to register a startup script every time a partial update occurs, regardless of where the update is done.

Please change this back so that the Page.ClientScript.RegisterStartupScript method can be used!

Einar

I need a page based RegisterStartupScript as well. I haven't seen anything from Microsoft mentioning that they would bring this back. Is there a way to run Java Script from a class file?

Thanks,

Jennifer


We can't properly support RegisterStartupScript itself since there's no way to know what people registered. However, we're considering an option to allow people to call a new method (or perhaps change an existing method) to register scripts that should always get included in the async post.

Thanks,

Eilon


Thats great news Eilon, crossing my fingers, would simplify things a great deal :-)

By the way, big thanks to the team for all the great sessions in Barcelona last week!

Einar


Eilon,

This would be great. If the RegisterStartupScript of the ScriptManager did not require a reference to a control in an update panel, life would be much easier. Thanks,

Mark

Saturday, March 24, 2012

CascadingDropDownExtender - preselected value

I used the dropdown extender a lot and noticed now a strange behavior, that makes it kind of a showstopper, if there is no workaround:

I have three DropDownLists exactly like in the example of the Toolkit. Except for the first DropDownList all values are filled in via the DropDownExtender. I did not use the optional PromptText property, because I do want to have the first value in each DropDownList preselected. This looks OK, so if I change the value of the first DropDownExtender, the values update in a cascade and the first item of each dropdown seems to be preselected - perfect. But if a postback happens now, the actual DropDownLists are empty and no value is selected, they are only selected, if the user would go on and open the drop down list and really select a value only then the values are also visible on the server side.

Is there any method I could call on the extender or on the dropdownlist to make the values visible on the server after a postback without having the user to click on the combobox and select the same value he already sees? That would be kind of hard to explain...

The behavior is easily to reproduce with the example from the Toolkit, just change in CascadingDropDown.aspx

 <table> <tr> <td>Make</td> <td><asp:DropDownList ID="DropDownList1" runat="server" Width="170" /></td> </tr> <tr> <td>Model</td> <td><asp:DropDownList ID="DropDownList2" runat="server" Width="170" /></td> </tr> <tr> <td>Color</td> <td><asp:DropDownList ID="DropDownList3" runat="server" Width="170" AutoPostBack="true" /></td> </tr> </table> <asp:Button ID="Button1" runat="server" Text="Button" UseSubmitBehavior="false" OnClick="DropDownList3_SelectedIndexChanged" /> <br /> <ajaxToolkit:CascadingDropDown ID="CascadingDropDown1" runat="server" TargetControlID="DropDownList1" Category="Make" ServicePath="CarsService.asmx" ServiceMethod="GetDropDownContents" /> <ajaxToolkit:CascadingDropDown ID="CascadingDropDown2" runat="server" TargetControlID="DropDownList2" Category="Model" ServiceMethod="GetDropDownContentsPageMethod" ParentControlID="DropDownList1" /> <ajaxToolkit:CascadingDropDown ID="CascadingDropDown3" runat="server" TargetControlID="DropDownList3" Category="Color" ServicePath="~/CascadingDropDown/CarsService.asmx" ServiceMethod="GetDropDownContents" ParentControlID="DropDownList2" />

ups... always learning... there is a "isDefault" flag on the CascadingDropDownValue collection, that just has to be set... problem solved!