Fórum criando uma janela modal com ajax. #5607
14/05/2009
0
estou usando o VS.2008 com SP1, ele já vem com ajax instalado né?
estou fazendo da seguinte maneira.
<asp:LinkButton ID="lnkEdite" runat="server" onclick="LinkButton1_Click">Editar</asp:LinkButton>
<aspanel ID="Panel1" runat="server" CssClass="modalPopup" Style="display: none" width="233px">
<p>Você deseja continuar?</p>
<br />
<div align="center">
<asp:Button ID="OkButton" runat="server" Text="OK" CommandName="Delete"
OnClick="OkButton_Click" />
<asp:Button ID="CancelButton" runat="server" Text="Cancel"
onclick="CancelButton_Click" />
</div>
</aspanel>
<ajaxtoolkit:modalpopupextender ID="ModalPopupExtender1" runat="server"
TargetControlID="lnkEdite"
PopupControlID="Panel1"
BackgroundCssClass="manage"
DropShadow="true"
OkControlID="OkButton"
OnOkScript="onOk()"
CancelControlID="CancelButton"
PopupDragHandleControlID="Panel3" />
mais está ocorrendo o seguinte erro:
Error 1 Unknown server tag 'ajaxtoolkit:modalpopupextender'.
Lorena Menelli
Curtir tópico
+ 0Posts
14/05/2009
Luiz Maia
Gostei + 0
15/05/2009
Lorena Menelli
Mais a que eu adicionei não aparece, tmb existe um monte de pasta numerada. Tá muito estralho, o disco v de imagem.
-----------------------------------------------------------------------------------------------------------------------------------------------
voltando ao erro ModalPopExtender
Erro Creating Control: ModalPopupExtender1
This control connot be displayed because its TagPrefix is not registred in the Web Form.
Gostei + 0
15/05/2009
Lorena Menelli
Exception Details: System.InvalidOperationException: The TargetControlID of 'ConfirmButtonExtender1' is not valid. The value cannot be null or empty.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException: The TargetControlID of 'ConfirmButtonExtender1' is not valid. The value cannot be null or empty.] System.Web.UI.ExtenderControl.RegisterWithScriptManager() +326661 System.Web.UI.ExtenderControl.OnPreRender(EventArgs e) +19 AjaxControlToolkit.ExtenderControlBase.OnPreRender(EventArgs e) +32 System.Web.UI.Control.PreRenderRecursiveInternal() +80 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.Control.PreRenderRecursiveInternal() +171 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842
Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053
Gostei + 0
15/05/2009
Luiz Maia
Gostei + 0
15/05/2009
Lorena Menelli
Gostei + 0
15/05/2009
Lorena Menelli
Panas isso, mais não está funcionando, instalei o AjaxControlToolkit.dll o ASPAJAXExtSetup e ASPNETAJAXVS2008.
mais não aparece a propiedade ConfirmButtonExtender.
<cc1:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server"
BehaviorID="btnEditar" TargetControlID="Button1">
</cc1:ConfirmButtonExtender>
<br />
<asp:Button ID="Button1" runat="server" Text="Button" />
Server Error in '/Hoffmann1' Application. The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /Hoffmann1/Manage/Categorias/Default2.aspx
Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053
Gostei + 0
16/05/2009
Luiz Maia
Gostei + 0
18/05/2009
Lorena Menelli
Gostei + 0
18/05/2009
Lorena Menelli
olha o meu codigo.
<asp:GridView ID="grdCategoris" runat="server" AutoGenerateColumns="False"
BackColor="White" BorderColor="#666666" BorderStyle="Solid" BorderWidth="1px"
CellPadding="3" DataSourceID="dsCategories"
GridLines="Vertical" Height="160px"
onselectedindexchanged="g_SelectedIndexChanged" Width="283px"
AlternatingRowStyle-BorderColor="#666666" HorizontalAlign="Center">
<RowStyle BackColor="#EEEEEE" ForeColor="Black" BorderColor="#666666"
BorderStyle="Solid" />
<EmptyDataRowStyle BorderStyle="Solid" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="Button1" runat="server" Text="Button" />
/
<asp:LinkButton ID="lnkExcluir" runat="server" CommandName="Delete"
onclick="LinkButton2_Click">Excluír</asp:LinkButton>
<cc1:ConfirmButtonExtender ID="ConfirmButtonExtender2" runat="server"
BehaviorID="nkExcluir" TargetControlID="lnkExcluir" ConfirmText="Tem certeza que deseja excluír essa categoria?">
</cc1:ConfirmButtonExtender>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Title" HeaderText="Título" SortExpression="Title" />
</Columns>
<FooterStyle BackColor="#848484" ForeColor="Black" BorderStyle="Solid" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center"
BorderWidth="1" BorderColor="#333333" Font-Size="11" BorderStyle="Solid" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White"
BorderColor="#666666" BorderStyle="Solid" />
<HeaderStyle BackColor="#FF9900" Font-Bold="True" ForeColor="White"
BorderStyle="None" BorderColor="#666666" BorderWidth="1" Font-Size="Small"
Font-Names="Tahoma" />
<EditRowStyle BorderStyle="Solid" />
<AlternatingRowStyle BackColor="#DCDCDC" BorderColor="#666666"
BorderStyle="Solid" />
</asp:GridView>
Gostei + 0
18/05/2009
Luiz Maia
Gostei + 0
19/05/2009
Lorena Menelli
Eu quero que todas as linhas do meu Grid, que contenhão o botão excluir esteja associado um ConfirmButtonExtender. Até agora só está funcionando na primeira linha do Grid.
O projeto tem uma classe chamada category que contem os metodos de select, update, exluir etc...
Nesse caso o código que vc me mandou devou colocar dentro da classe.
protected void ProductsGridView_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == “Modify”) //não estou entendendo nada. { Product record = SelectRecord(Convert.ToInt32(e.CommandArgument)); ProductId.Text = record.ProductID.ToString(); // nem isso! ProductName.Text = record.ProductName.ToString(); UnitsInStock.Text = record.UnitsInStock.Value.ToString(); UnitPrice.Text = record.UnitPrice.Value.ToString(); ModalPopupExtender mpe = up1.ContentTemplateContainer.FindControl(“mpe”) as ModalPopupExtender; mpe.Show(); //nossa, tô boiando... } }
<asp:ObjectDataSource ID="dsCategories" runat="server" DeleteMethod="DeleteCat"
InsertMethod="Insert" OldValuesParameterFormatString="original_"
SelectMethod="SelectCategory" TypeName="DevMedia.ECommerce.Category">
<DeleteParameters>
<asp:Parameter Name="CategoryId" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="title" Type="String" />
</InsertParameters>
</asp:ObjectDataSource>
da uma olhada no projeto:
https://www.devmedia.com.br/imagens/discovirtual/211069/Hoffmann1-3.rar
Gostei + 0
19/05/2009
Lorena Menelli
:-)
Gostei + 0
20/05/2009
Lorena Menelli
Pelo que estava vendo aqui, o que eu consegui fazer é apenas abrir uma janela de confirmação no java script.
Na verdade esse assunto é antigo eu eu já havia aberto um post para tentar resolver essa questão da Janela Modal.
Estou fazendo o curso "Curso Crie uma loja virtual completa com Visual Studio e ASP.NET" de FABIO GALANTE MANS.
O meu problema é que ele usa uma classe chamada OpenWebWindows que complica demais as coisa. Conforme ele mesmo disse, quando ele fez os videos dessa video aula não existia os controles ajax toolkit, devido isso estou com muita duvida na hora de criar a janela moda, que é explicada no video part VIII:
link do video:
https://www.devmedia.com.br/articles/viewcomp.asp?comp=4112
Até agora eu consegui fazer a janela modal funcionar usando ModalPopup, do toolkit
http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ModalPopup/ModalPopup.aspx
Porém usando o TargetControlID com o LinkButton1 fora do TemplateField. Como mostrado abaixo.
O que estou precisando é usar o TargetControlID com o LinkButton1 que está dentro do me TemplateField.
Como posso fazer isso??
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lbnEdite" runat="server" CommandName="Select">Edite</asp:LinkButton>
/
<asp:LinkButton ID="lnkExcluir" runat="server" CommandName="Delete"
onclick="LinkButton2_Click"
onclientclick="return confirm('Tem certeza que deseja excluír essa categoria? ATENÇÃO: Todos os dados serão perdidos. ')">Excluír</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
------------------------------------------------------------------------------------------------------------------------------------------------
Assim funciona.
<asp:LinkButton ID="LinkButton1" runat="server" Text="Abrir"></asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server" Text="Fechar"></asp:LinkButton>
<asp:Panel ID="PnUp" runat="server" Width="197px">
<asp:Panel ID="PnTitulo" runat="server" Height="25px" style="color: #FFFFCC" Width="196px">
<div class="back">
<table style="width:196px; height: 7px;">
<tr>
<td>
lindinha </td>
</tr>
</table>
</div>
</asp:Panel>
<div class="back">
<asp:FormView ID="PnUpload" runat="server" DataSourceID="dsCategoriesUpDate"
DefaultMode="Edit" Height="126px" Width="152px">
<EditItemTemplate>
Title:
<asp:TextBox ID="txtTitle" runat="server" Text='<%# Bind("Title") %>' />
<br />
<asp:Button ID="UpdateButton" runat="server" CausesValidation="True"
CommandName="Update" Text="Update" />
<asp:Button ID="UpdateCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel" />
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"></asp:RequiredFieldValidator>
</EditItemTemplate></asp:FormView>
</div>
</asp:Panel>
<cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="LinkButton1" CancelControlID="LinkButton2" PopupControlID="PnUp" PopupDragHandleControlID="PnTitulo" RepositionMode="RepositionOnWindowResizeAndScroll" OnOkScript="onOk()" Drag="True" DropShadow="True" X="150" Y="150">
</cc1:ModalPopupExtender>
Gostei + 0
20/05/2009
Lorena Menelli
https://www.devmedia.com.br/imagens/discovirtual/211069/Hoffmann1-4.rar
Gostei + 0
20/05/2009
Fabio Mans
<asp:GridView ID="GvwGrupoCategoria" runat="server" AutoGenerateColumns="False" DataKeyNames="GrupoCategoriaID"
OnRowCommand="GvwGrupoCategoria_RowCommand" OnRowCreated="GvwGrupoCategoria_RowCreated"
OnRowDataBound="GvwGrupoCategoria_RowDataBound">
<Columns>
<asp:ButtonField ButtonType="Image" HeaderImageUrl="~/Images/arrow-right_cinza.gif"
ImageUrl="~/Images/arrow-right_cinza.gif" CommandName="Selecao" />
<asp:BoundField DataField="GrupoCategoria" HeaderText="Grupo Categoria" >
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:TemplateField HeaderText="Tipo">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("TextoTipo") %>'></asp:Label>
<asp:HiddenField ID="HdfTipo" runat="server" Value='<%# Eval("Tipo") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:ButtonField ButtonType="Image" CommandName="Excluir" ImageUrl="~/Images/excluir.png"
Text="Excluir categoria">
<ItemStyle HorizontalAlign="Center" />
</asp:ButtonField>
</Columns>
</asp:GridView>
Em seguida no RowCommand no Evento RowCommand voce exibe o Modal
protected void GvwGrupoCategoria_RowCommand(object sender, GridViewCommandEventArgs e)
{
int categoria = Convert.ToInt32(GvwGrupoCategoria.DataKeys[Convert.ToInt32(e.CommandArgument)][0]);
if (e.CommandName == "Selecao")
{
string idGrupo =
Convert.ToInt32(GvwGrupoCategoria.DataKeys[Convert.ToInt32(e.CommandArgument)][0]).ToString();
HfdAlterar.Value = idGrupo;
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = GvwGrupoCategoria.Rows[index];
TxtAlterarDescricao.Text = Limpar(row.Cells[1].Text);
HiddenField hdfTipoGrid = (HiddenField)GvwGrupoCategoria.Rows[index].FindControl("HdfTipo");
RbTipoAlteracao.SelectedValue = hdfTipoGrid.Value.Equals("C") ? "C" : "D";
ModalAlterar.Show();
}
}
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)