-1

I have a modalpopup which is showed automaticaly on startup of page. I'm doing this on Page_Load event.

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            InitiallizeAll();
        }
    }

    private void InitiallizeAll()
    {
        ModalPopupExtender1.Show();
    }

In aspx side I have a dropdownlist on a modalpopup but the index is always posting zero to the javascript code.

    <asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server"           
                            TargetControlID="lnkPopup"
                            PopupControlID="panEdit" 
                            BackgroundCssClass="modalBackground" 
                            OkControlID="btnGonder"
                            OnOkScript="onOk()">
    </asp:ModalPopupExtender>
<asp:Panel ID="panEdit" runat="server" Height="180px" Width="400px" CssClass="modalPopup">
    <table width="100%">
        <tr>
            <td class="labelCell">
                <asp:Label ID="lblBolge" Text="Bölge" runat="server" />
            </td>
            <td>
                <asp:DropDownList ID="ddlIl" runat="server" 
                                  AutoPostBack="False" 
                                  DataTextField="Isim"
                                  DataValueField="Id" 
                                  DataSourceID="ObjectDataSource1" 
                                  Width="176px">
                </asp:DropDownList>
                <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
                                      SelectMethod="GetAllIl"
                                      TypeName="ERK.Lasos.Business.CustomEntities.Il">
                    <SelectParameters>
                        <asp:QueryStringParameter DefaultValue="0" 
                                                  Name="ilId" 
                                                  QueryStringField="bolge"
                                                  Type="Int32" />
                    </SelectParameters>
                </asp:ObjectDataSource>
            </td>
        </tr> 
    </table>
    <br />
    <asp:Button ID="btnGonder" runat="server" Text="Devam Et" />
</asp:Panel>
<a id="lnkPopup" runat="server">Show Popup</a>

And this is my javascript code

        <script type="text/javascript">
        function onOk() {
        var e = document.getElementById("ddlIl");
        var selectedIlId = e.options[e.selectedIndex].value;
        window.location = "/Pages/AnaSayfa/LasosAnaSayfa.aspx?bolge=" + selectedIlId;
        }
        </script>

But I'm always getting selectedIlId is "0". Value is not changing whatever I select from dropdownlist

DavRob60
  • 3,517
  • 7
  • 34
  • 56
rblerk
  • 17
  • 1
  • 1
  • 10

1 Answers1

0

First, you should check if you got the good selected index. :

Replace temporally var selectedIlId = e.options[e.selectedIndex].value; by var selectedIlId = e.selectedIndex;

If it's OK, you should check you data source by making sure the Id field is correct, the easiest way to to this is to set DataTextField="Id" to your DropdownList and check the values that appears in it.

DavRob60
  • 3,517
  • 7
  • 34
  • 56
  • thx for reply i solved this problem with using code-behing button_click() event. javascript solution did not work for me – rblerk May 07 '12 at 11:47
  • This is not an help forum, asking question and just saying you solved *your* problem is not a recommended behavior. You will probably be down-voted and you post will be ignored if you continue on this path. – DavRob60 May 07 '12 at 11:58
  • i'm sorry but i dont know what should i do in this sitution. i just wanted to answer your recommendation – rblerk May 08 '12 at 12:15