Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeUsing DNN Platf...Using DNN Platf...Language and In...Language and In...localizing ListItem, CheckBoxList, ETClocalizing ListItem, CheckBoxList, ETC
Previous
 
Next
New Post
1/17/2008 4:21 PM
 

After changing my ListBox to a DropDownList I noticed another issue and it could just be me so forgive me if I'm just doing it wrong but here goes.

Ok so I have a CustomControl this control is made up of several Panels of which some are hidden and others are not based on the users progress through the questionnaire.

Markup Snippet:

 <asp:Label ID="Sec1Q8Label" resourcekey="Sec1Q8Label" runat="server" />
 <asp:DropDownList ID="Sec1Q8"  OnSelectedIndexChanged="Sec1Q8SelectChanged" runat="server" Rows="1" CausesValidation="false" AutoPostBack="true">
  <asp:ListItem resourcekey="Sec1Q8Option0" />
  <asp:ListItem resourcekey="Sec1Q8Option1" />
  <asp:ListItem resourcekey="Sec1Q8Option2" />
  <asp:ListItem resourcekey="Sec1Q8Option3" />
  <asp:ListItem resourcekey="Sec1Q8Option4" />
  <asp:ListItem resourcekey="Sec1Q8Option5" />
  <asp:ListItem resourcekey="Sec1Q8Option6" />
  <asp:ListItem resourcekey="Sec1Q8Option7" /> 
 </asp:DropDownList>

 <asp:Label ID="Sec1Q8OtherLabel" resourcekey="Sec1Q8OtherLabel" runat="server" Visible="false" />
 <asp:TextBox ID="Sec1Q8Other" resourcekey="Sec1Q8Other" runat="server" Visible="false" />

 

Code Snippet:

        protected void Sec1Q8SelectChanged(object sender, EventArgs e)
        {
            if (((DropDownList)sender).SelectedIndex == 7)
            {
                Sec1Q8OtherLabel.Visible = true;
                Sec1Q8Other.Visible = true;

            }
            else
            {
                Sec1Q8OtherLabel.Visible = false;
                Sec1Q8Other.Visible = false;
            }
        }

 

Now the problem is this in the PostBack the DropDownList appears to be rebuild from scratch nulling out the selection. The same is true for RadioButtonList, I haven't tested any other than standard TextBox which is NOT regenerated and DOES retain its inputted value. I know this control works in a normal web form environment but prehaps I have got in over my head as far as understanding how DNN is implementing the web form.

Any information would be great.

Thanks again,

Josh

PS.

I did report the enhancement you wanted me to do Sebastian

 
New Post
1/17/2008 11:06 PM
 

Odd - I don't see thing obvious in your markup or code that would cause loss of the selected item on a post back. Although I've never coded a DDL with Rows=1 and don't think that is the problem, you might try it without the Rows attribute or with Rows=# higher than 1. You havn't disabled Viewstate for the DDL or the entire .ascx control have you?  Are there other modules/controls on the page that may be triggering their own postback? Are you using an Ajax Update panel or have you enabled "supports partial rendering" in the module definitions? Are you doing a Response.Redirect back to this control from another control such as a detail view? This would not be considered a postback and would reset the DDL's selected index.

As this is unrelated to the original post, you may wish to start a new thread in the Extend It !(Asp.Net 2.0) forum.


Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
New Post
1/18/2008 8:31 AM
 

Hi Josh,

Is SelectedIndex Null, -1, or 0?  Try assigning some unique values to your ListItem's

Thanks,
Mike

 
New Post
1/18/2008 10:22 AM
 

Its not actually null it is 0 regardless of your selection and there is not value even though the value was listed when you made the selection. I can almost guarantee that it has to do with localization. I think that when the postback is requested the localization is started again clearing out localizaed values however the post is then completed before the localization is completed. Thus I get a SelectedIndex of 0 and a blank value.

This is crazy, I have to be doing something wrong because I can't imagine that I am the only one that has put a custom control questionnaire in a module before.

 
New Post
1/18/2008 11:57 AM
 

Mike is on the right track - without each ListItem having a unique value, the ASP.Net's determination of the selected item will always return the first matching, that is, the first item in the list.  In the control localization method in DotNetNuke.Framework.PageBase the following sets each ListItems Text property but does nothing to set the Value property:

If Not key Is Nothing Then
      Dim value As String = Services.Localization.Localization.GetString(key, ResourceFileRoot)
      If value <> "" Then
           ctrl.Items(i).Text = value
      End If
End If

Although you might want to add another bug report to Gemini for this, I'm not sure I would want to add any extra processing steps list control localization as most developers will provide a unique value to each list item as part of the markup. Try assigning a unique value (i.e. 0, 1, 2, 3 . . .) to each ListItem and let us know what happens.


Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Language and In...Language and In...localizing ListItem, CheckBoxList, ETClocalizing ListItem, CheckBoxList, ETC


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out