Modalpopupextender panel, into a gridview
i've a problem. Follow the source code
<asp:GridView ID="gvMonitor" runat="server" AutoGenerateColumns="False" DataKeyNames="ticket_id"
DataSourceID="dsTicket" AllowPaging="True" AllowSorting="True" CellPadding="8"
ForeColor="#333333" GridLines="None">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton runat="server" ID="btnCambiaStato" ImageUrl="/images/status.png"
ToolTip="Cambia stato ticket" Height="24px" CommandName="CambiaStato" Width="24px" />
<asp:ImageButton runat="server" ID="ImageButton2" ImageUrl="/images/icon_history.jpg"
ToolTip="Storico ticket" Height="24px" CommandName="StoriaTicket" Width="24px" />
<asp:ModalPopupExtender ID="mpeCambiaStato" runat="server" TargetControlID="btnCambiaStato"
PopupControlID="panelCambiaStatoTicket" BackgroundCssClass="modalBackground"
DropShadow="true" OkControlID="btnConfermaCambioStato" OnOkScript="onOk()" CancelControlID="btnCancellaCambioStato" />
<asp:Panel runat="server" ID="panelCambiaStatoTicket" Style="background-color: White;
padding: 10px 10px 10px 10px; border-color: Black; border-width: 1px; border-style: solid;">
Seleziona il nuovo stato del Ticket
<asp:DropDownList runat="server" ID="cmbStatoTicket">
<asp:ListItem Text="Aperto" Value="A"></asp:ListItem>
<asp:ListItem Text="Chiuso" Value="C"></asp:ListItem>
</asp:DropDownList>
<br />
<br />
Inserisci una nota di avanzamento (opzionale)
<br />
<asp:TextBox runat="server" ID="txtNotaAvanzamento" TextMode="MultiLine" Text=""
Height="60px" Width="24开发者_C百科0px"></asp:TextBox>
<br />
<asp:Button runat="server" ID="btnConfermaCambioStato" Text="Conferma" />
<asp:Button runat="server" ID="btnCancellaCambioStato" Text="Cancella" />
</asp:Panel>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ticket_id" HeaderText="Nr Ticket" InsertVisible="False"
ReadOnly="True" SortExpression="ticket_id" />
The problem is, that when i click btnConfermaCambioStato , asp.net don't rise
Private Sub gvMonitor_RowCommand(sender As Object, e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gvMonitor.RowCommand If (e.CommandName = "CambiaStato") Then
Why ? Thanks
First, it's because there is no CommandName
in the btnConfermaCambioStato
Button.
When you click on the btnCambiaStato
, the gvMonitor_RowCommand should be raised, but it's absorbed by the ModalPopupExtender so it could show the popup Client side without posting back. but it's co in this case because you don't want to postback until the action is confirmed.
If you want to raise the event when you click on btnConfermaCambioStato
, you should the add a CommandName to the Button that trigger the event.
<asp:Button runat="server" ID="btnConfermaCambioStato"
Text="Conferma"
CommandName="ConfermaCambiaStato" />
But it wont work either because you specified it to be the OkControl of the ModalPopupExtender, this tell the ModalPopupExtender to absorb the event and handle it client side by running the onOk()
javascript function.
OkControlID="btnConfermaCambioStato" OnOkScript="onOk()"
So, you probably want to remove those 2 property so you could handle the btnConfermaCambioStato
's click event on the serverside using the gvMonitor_RowCommand
event. That answer the "Why ?"
But I think you wont be out of trouble by knowing that. Depending of what you want to do, in the gvMonitor_RowCommand
, you will probably have set your gridview as a asyncpostbacktrigger of an updatepanel to handle it smoothly, you could then hide the ModalPopupExtender on server side and then update whatever you need to in that update panel. But I'm just speculating here.
精彩评论