1

I have a div , within which I have a button and an asp.net dropdownlist. I see that the dropdownlist value doesnt change. ie. If I select 30 from the dropdownlist, the selected value is still shown as the default value which is 15, Same thing happens when I select 1Hr , 2Hrs , 48Hrs etc.

aspx

      <div id='one'>
     <asp:LinkButton ID="ConfigureAlerts" OnClick="btnConfigureAlerts_Click" runat="server">Configure Alerts</asp:LinkButton>
    </div>
    <div id="ViewModalPopupDiv2">
            <asp:UpdatePanel ID="UpdatePanel3" runat="server">
                <ContentTemplate>
                <asp:Panel ID="Panel2" runat="server" HorizontalAlign="left" ScrollBars="Auto">
                <asp:Button ID="btnGetLogs" runat="server" Text="SendAlerts" OnClick="btnSendAlertEmail_Click"/>
<asp:Label ID="Label2" runat="server" Text="Set The Alert Email Interval to every :" CssClass="label"
                                    ForeColor="Black"></asp:Label>&nbsp&nbsp&nbsp
           <asp:DropDownList ID="ddlTimeInterval" runat="server" AutoPostBack="true" UseSubmitBehavior="false" >
                                    <asp:ListItem Text="15MIN" Value="15"></asp:ListItem>
                                    <asp:ListItem Text="30MIN" Value="30"></asp:ListItem>
                                    <asp:ListItem Text="1Hr" Value="60"></asp:ListItem>
                                    <asp:ListItem Text="2Hrs" Value="120"></asp:ListItem>
                                    <asp:ListItem Text="8Hrs" Value="480"></asp:ListItem>
                                    <asp:ListItem Text="24Hrs" Value="1440"></asp:ListItem>
                                    <asp:ListItem Text="48Hrs" Value="2880"></asp:ListItem>
                                </asp:DropDownList>
                                <br />                
</asp:Panel>
                </ContentTemplate>
            </asp:UpdatePanel>
        </div>

javascript

function ViewModelPopup2() {
        $("#ViewModalPopupDiv2").dialog({
                scrollable: true,
                width: 800,
                modal: true
            });
        }

aspx.cs

protected void btnSendAlertEmail_Click(object sender, EventArgs e)
        {

            // Code to send email

        }

protected void btnConfigureAlerts_Click(object sender, EventArgs e)
        {

        ScriptManager.RegisterStartupScript
                       (this, this.GetType(), "callScriptFunction", "ViewModelPopup2();", true);
        }
    }

Any Suggestions on what I can do ?

3
  • When you say it doesn't change, do you mean on postback or does the dropdown list not physically show the new value you selected? Commented Sep 11, 2013 at 15:37
  • the dropdown list does not physically show the new value selected Commented Sep 11, 2013 at 15:39
  • Is there any specific reason why you have those AutoPostBack set to true? I don't see you bind any events to those DDL, so you might as well take that off. Commented Sep 11, 2013 at 15:39

2 Answers 2

1

You have AutoPostBack set against the drop down list. Having that set means it's posting back and refreshing the control which causes the default value to be selected.

Sign up to request clarification or add additional context in comments.

2 Comments

Hey thanks ! On removing the autopostback property , I am able to select values from the dropdownlist, but as soon as I click the button, the dropdownlist again goes back to the initial value
You need to add something in the page load / postback event that sets the selected value of that drop down list.
0
<asp:button Id=" btnConfigureAlerts" runat="Server" OnClientClick="ViewModelPopup2()"></asp:button>

function ViewModelPopup2() {
        $("#ViewModalPopupDiv2").dialog({
                scrollable: true,
                width: 800,
                modal: true
            });
        };

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.