Hi there,
We are in the process of upgrading the telerik controls in our project from Telerik Controls ASP.NET AJAX Q1 2008 to Telerik Controls ASP.Net AJAX Q2 2009 (Yes its Q1 2008 to Q2 2009).
We discovered a weird behaviour on the RadComboBox that was working fine in the Q1 2008 version where the selected item is not updated at all.
The webpage in question generates the controls dynamically such that every time the submit button is click, it submits the current page and parses the next page controls.
The entire process in brief can be describe in the following:
2. The web application selects the appriopriate node to display based on a index and translates the xml into a string of text using xslt.
3. The resulting string would end up looking exactly like a typical aspx code. e.g.
4. This string is then added to the webpage through Page.ParseControl(string). where all the controls are added to a placeholder.
5. User keys in the values and submits the page where the values would then be written back into the xmlDocument, processed and the next xmlnode would be selected to be displayed. this would continue until there is nothing left to be displayed and the xmldocument will then be saved.
I hope you guys arent lost in my explaination of how things work till now.. but in summary, its basically
xmldocument --> xslt translation --> string of aspx code --> binded to page using page.parsecontrol() -->get next node in xmldocument when user clicks submit. --> repeat all over again.
Ok. The weird behaviour where the selected item is not displayed happens when a single node that has a previously selected value or default selected value is being displayed. (see e.g. 3 above where the item "Captain" is selected.) If the user selects a different item in the list, like "Mr" on the same example, this item would now be selected. and would be saved back in the document. However, the selected item is not reflected back onto the radcomboBox even though a new item is selected. the radcombobox instead retains the "Captain" as the selected item. see flow below. of the debugging we went through.
xmldocument --> xslt translation --> string of aspx code --> binded to page using page.parsecontrol() --> radcombobox default value is "Captain"-->user selects "Mr" in combobox and clicks submit. --> "Mr" is written back in the xmldocument. --> system notices a change in the node, saves the change and retrieves updated node (same node) where "Mr" is now the selected item --> xslt translation--> string of aspx code (Where "Mr" is selected item) --> binded to page using page.parsecontrol(). ["Captain" is now selected]-->
radcomboBox selected item is "captain" when displayed to the user.
The moment the string is binded using page.parseControl(), the selected item was reverted back to the original item. but if we copied the snipper of page.Parsecontrol, from line 17 to line 21 and pasted it after line 21, the correct selected item would be persisted on the combobox.
One small note. The code here is being used in a RadWindow.
Can anyone help?
We are in the process of upgrading the telerik controls in our project from Telerik Controls ASP.NET AJAX Q1 2008 to Telerik Controls ASP.Net AJAX Q2 2009 (Yes its Q1 2008 to Q2 2009).
We discovered a weird behaviour on the RadComboBox that was working fine in the Q1 2008 version where the selected item is not updated at all.
The webpage in question generates the controls dynamically such that every time the submit button is click, it submits the current page and parses the next page controls.
The entire process in brief can be describe in the following:
- An xml document (comprising of xmlnodes where each node is a possible page to be displayed) is loaded from the database and stored in session. See eg. of a single node with 1 RadComboBox.
<item name="PostalAddressState" displaySource="" dataSource="" label="State" control="DropDownList" direction="Horizontal" required="True" entityColumnName="Address.State" entityType="PostalAddress" width="80px"> <field label="Select" value="0" selected="False" fieldType="String" goTo=""/> <field label="ACT" value="ACT" selected="False" fieldType="String" goTo=""/> <field label="NSW" value="NSW" selected="False" fieldType="String" goTo=""/> <field label="NT" value="NT" selected="False" fieldType="String" goTo=""/> <field label="QLD" value="QLD" selected="False" fieldType="String" goTo=""/> <field label="SA" value="SA" selected="False" fieldType="String" goTo=""/> <field label="TAS" value="TAS" selected="False" fieldType="String" goTo=""/> <field label="VIC" value="VIC" selected="False" fieldType="String" goTo=""/> <field label="WA" value="WA" selected="True" fieldType="String" goTo=""/> </item>
2. The web application selects the appriopriate node to display based on a index and translates the xml into a string of text using xslt.
<telerik:RadComboBox id="rcb{@id}" runat="server" Skin="WebBlue" AllowCustomText="false" MarkFirstMatch="true" |
HighlightTemplatedItems="true" width="{@width}" EnableItemCaching="false"> |
<items> |
<xsl:for-each select="field"> |
<xsl:choose> |
<xsl:when test="@selected='True'"> |
<telerik:RadComboBoxItem Value="{@value}" Selected="{@selected}" text="{@label}" /> |
</xsl:when> |
<xsl:otherwise> |
<telerik:RadComboBoxItem Value="{@value}" text="{@label}" /> |
</xsl:otherwise> |
</xsl:choose> |
</xsl:for-each> |
</items> |
</telerik:RadComboBox> |
3. The resulting string would end up looking exactly like a typical aspx code. e.g.
<telerik:RadComboBox id="rcbID24" runat="server" Skin="WebBlue" AllowCustomText="false" MarkFirstMatch="true" HighlightTemplatedItems="true" width="100px" EnableItemCaching="false"> |
<items> |
<telerik:RadComboBoxItem Value="0" text="Select" /> |
<telerik:RadComboBoxItem Value="Br" text="Br" /> |
<telerik:RadComboBoxItem Value="Captain" Selected="True" text="Captain" /> |
<telerik:RadComboBoxItem Value="Dr" text="Dr" /> |
<telerik:RadComboBoxItem Value="Father" text="Father" /> |
<telerik:RadComboBoxItem Value="Miss" text="Miss" /> |
<telerik:RadComboBoxItem Value="Mr" text="Mr" /> |
<telerik:RadComboBoxItem Value="Mrs" text="Mrs" /> |
<telerik:RadComboBoxItem Value="Ms" text="Ms" /> |
<telerik:RadComboBoxItem Value="Professor" text="Professor" /> |
<telerik:RadComboBoxItem Value="Rev" text="Rev" /> |
<telerik:RadComboBoxItem Value="Sir" text="Sir" /> |
<telerik:RadComboBoxItem Value="Sr" text="Sr" /> |
<telerik:RadComboBoxItem Value="The Hon." text="The Hon." /> |
</items> |
</telerik:RadComboBox> |
4. This string is then added to the webpage through Page.ParseControl(string). where all the controls are added to a placeholder.
5. User keys in the values and submits the page where the values would then be written back into the xmlDocument, processed and the next xmlnode would be selected to be displayed. this would continue until there is nothing left to be displayed and the xmldocument will then be saved.
I hope you guys arent lost in my explaination of how things work till now.. but in summary, its basically
xmldocument --> xslt translation --> string of aspx code --> binded to page using page.parsecontrol() -->get next node in xmldocument when user clicks submit. --> repeat all over again.
Ok. The weird behaviour where the selected item is not displayed happens when a single node that has a previously selected value or default selected value is being displayed. (see e.g. 3 above where the item "Captain" is selected.) If the user selects a different item in the list, like "Mr" on the same example, this item would now be selected. and would be saved back in the document. However, the selected item is not reflected back onto the radcomboBox even though a new item is selected. the radcombobox instead retains the "Captain" as the selected item. see flow below. of the debugging we went through.
xmldocument --> xslt translation --> string of aspx code --> binded to page using page.parsecontrol() --> radcombobox default value is "Captain"-->user selects "Mr" in combobox and clicks submit. --> "Mr" is written back in the xmldocument. --> system notices a change in the node, saves the change and retrieves updated node (same node) where "Mr" is now the selected item --> xslt translation--> string of aspx code (Where "Mr" is selected item) --> binded to page using page.parsecontrol(). ["Captain" is now selected]-->
radcomboBox selected item is "captain" when displayed to the user.
The moment the string is binded using page.parseControl(), the selected item was reverted back to the original item. but if we copied the snipper of page.Parsecontrol, from line 17 to line 21 and pasted it after line 21, the correct selected item would be persisted on the combobox.
// transformedContent is the output from xslt. | |
string transformedContent = obj.GetHtml(Context); | |
Control ctrl = new Control(); | |
ctrl = Page.ParseControl(transformedContent); | |
// Debug statement to show that the combobox in question retains the correct selected value. | |
foreach (Control ccc in ctrl.Controls) | |
{ | |
if (ccc is RadComboBox && ccc.ID == "rcbID24") | |
{ | |
string vvv = ((RadComboBox)ccc).SelectedValue; | |
} | |
} | |
// Clear and dispose of any controls from any previously parsed node. | |
pclXmlOutput.Controls.Clear(); | |
pclXmlOutput.Dispose(); | |
// Add the NEW control. | |
pclXmlOutput.Controls.Add(ctrl); | |
// Check to see if the comboBox has changed its value. | |
foreach (Control ccc in ctrl.Controls) | |
{ | |
if (ccc is RadComboBox && ccc.ID == "rcbID24") | |
{ | |
string vvv = ((RadComboBox)ccc).SelectedValue; | |
} | |
} |
One small note. The code here is being used in a RadWindow.
Can anyone help?