我已经看到许多听起来与我的问题相同的问题,但是所有这些问题都是关于不同的场景的,并且我还没有找到解决我问题的方法。在模式对话框中单击asp:LinkButton lnkInit之后,IsPostback始终为false,并且永远不会调用事件处理程序。这是代码:
<%@ Page Language="vb" AutoEventWireup="false" MasterPageFile="~/Pricebook/My.Master" CodeBehind="default.aspx.vb" Inherits="MyWebCore.Pricebook._default"
...
<div id="modal_customer" class="modal fade modal_customer" role="dialog" aria-labelledby="Select Your Customer" aria-describedby="Select a customer to generate a customizable pricelist" runat="server">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h2 class="modal-title">Select Your Customer</h2>
</div>
<div class="modal-body">
<div class="form-group">
<asp:Label ID="lblCustomer" AssociatedControlID="ddCustomer" Text="Customer Selection" runat="server"></asp:Label>
<asp:DropDownList id="ddCustomer" CssClass="form-control customer_list" runat="server" />
</div>
<asp:LinkButton ID="lnkInit" CssClass="btn btn-primary" text="Begin" runat="server"></asp:LinkButton>
</div>
</div>
</div>
</div>
隐藏代码:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
....
If Not IsPostBack Then
' ... Always gets here :(
End If
...
Sub lnkInit_Click(ByVal objSender As Object, ByVal objArgs As EventArgs) Handles lnkInit.Click
'... Never gets here
End Sub
另一个奇怪的事实是,当我在Visual Studio中运行该应用程序时,以及当我在Azure VM的IIS上将其作为QA Web应用程序运行时,但当我在以下环境中作为生产应用程序运行时,该应用程序的行为相同的IIS,它可以正常工作。我不知道该如何调试。
答案 0 :(得分:0)
将PostBackUrl添加到同一页面时,问题已解决:
<asp:LinkButton ID="lnkInit" CssClass="btn btn-primary" text="Begin" runat="server" PostBackUrl="~/pricebook/default.aspx"></asp:LinkButton>