我有一个modalpopup,它在页面启动时自动显示。我在 Page_Load 事件中这样做。
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
InitiallizeAll();
}
}
private void InitiallizeAll()
{
ModalPopupExtender1.Show();
}
在 aspx 方面,我在 modalpopup 上有一个下拉列表,但索引始终将零发布到 javascript 代码中。
<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>
这是我的 javascript 代码
<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>
但我总是让 selectedIlId 为“0”。值不会改变我从下拉列表中选择的任何内容