limmontreefree
asked on
Problem with a DataList ItemCommand if the page is use a MasterPage
I have an strange problem, If a use a MasterPage, the Itemcommand of DataList don't execute.
I've simplified the code to the minimun, and this is:
<%@ Master Language="VB" CodeFile="MasterPagePrueba s.master.v b" Inherits="MasterPagePrueba s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPa gePruebas. master" AutoEventWireup="true" EnableEventValidation="fal se" CodeFile="tiendas4.aspx.vb " Inherits="tiendas4" %>
<asp:Content ID="Content2" ContentPlaceHolderID="Cont entPlaceHo lder1" Runat="Server">
<asp:SqlDataSource ID="SqlDataSourceTiendas" runat="server"
ConnectionString="<%$ ConnectionStrings:Connecti onString %>"
SelectCommand="SELECT Member_Id, IdTienda, Nombre_Fiscal, Nombre_Comercial, Lema, Persona_Contacto, Calle, CodPostal, CodProvincia, Poblacion, email, web, Telefono, Fax, logo, activo FROM Tiendas"></asp:SqlDataSour ce>
<asp:DataList ID="DataListTiendas" runat="server" DataKeyField="IdTienda"
DataSourceID="SqlDataSourc eTiendas">
<ItemTemplate>
<span class="tienda_nombre"><asp :Label ID="Nombre_ComercialLabel" runat="server" Text='<%# Eval("Nombre_Comercial") %>' /></span><br />
<asp:Button ID="Button2" runat="server" Text=" Ver todos sus productos" CommandName="VerArticulosD elCliente" CommandArgument='<%# Eval("IdTienda") %>'/>
</ItemTemplate>
</asp:DataList>
</asp:Content>
Partial Class tiendas4
Inherits System.Web.UI.Page
Protected Sub DataListTiendas_ItemComman d(source As Object, e As System.Web.UI.WebControls. DataListCo mmandEvent Args) Handles DataListTiendas.ItemComman d
If e.CommandName = "VerArticulosDelCliente" Then
Dim strCodigoTienda As String = Trim(e.CommandArgument)
Session("IdTienda") = strCodigoTienda
Response.Redirect("Default .aspx?B=2" )
End If
End Sub
End Class
THIS VERSION DON0T WORK IY NEED THE BUTTON REDIRECT TO ANOTHER PAGE.
THIS OTHER VERSION WITOUT MASTER PAGE WORKS
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="tiendas3.aspx.vb " Inherits="tiendas3" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div id="contenido2">
<asp:SqlDataSource ID="SqlDataSourceTiendas" runat="server"
ConnectionString="<%$ ConnectionStrings:Connecti onString %>"
SelectCommand="SELECT Member_Id, IdTienda, Nombre_Fiscal, Nombre_Comercial, Lema, Persona_Contacto, Calle, CodPostal, CodProvincia, Poblacion, email, web, Telefono, Fax, logo, activo FROM Tiendas"></asp:SqlDataSour ce>
<asp:DataList ID="DataListTiendas" runat="server" DataKeyField="IdTienda"
DataSourceID="SqlDataSourc eTiendas">
<ItemTemplate>
<span class="tienda_nombre"><asp :Label ID="Nombre_ComercialLabel" runat="server" Text='<%# Eval("Nombre_Comercial") %>' /></span><br />
<asp:Button ID="Button2" runat="server" Text=" Ver todos sus productos" CommandName="VerArticulosD elCliente" CommandArgument='<%# Eval("IdTienda") %>'/>
</ItemTemplate>
</asp:DataList>
</form>
</body>
</html>
Partial Class tiendas3
Inherits System.Web.UI.Page
Protected Sub DataListTiendas_ItemComman d(source As Object, e As System.Web.UI.WebControls. DataListCo mmandEvent Args) Handles DataListTiendas.ItemComman d
If e.CommandName = "VerArticulosDelCliente" Then
Dim strCodigoTienda As String = Trim(e.CommandArgument)
Session("IdTienda") = strCodigoTienda
Response.Redirect("Default .aspx?B=2" )
End If
End Sub
End Class
I've simplified the code to the minimun, and this is:
<%@ Master Language="VB" CodeFile="MasterPagePrueba
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPa
<asp:Content ID="Content2" ContentPlaceHolderID="Cont
<asp:SqlDataSource ID="SqlDataSourceTiendas" runat="server"
ConnectionString="<%$ ConnectionStrings:Connecti
SelectCommand="SELECT Member_Id, IdTienda, Nombre_Fiscal, Nombre_Comercial, Lema, Persona_Contacto, Calle, CodPostal, CodProvincia, Poblacion, email, web, Telefono, Fax, logo, activo FROM Tiendas"></asp:SqlDataSour
<asp:DataList ID="DataListTiendas" runat="server" DataKeyField="IdTienda"
DataSourceID="SqlDataSourc
<ItemTemplate>
<span class="tienda_nombre"><asp
<asp:Button ID="Button2" runat="server" Text=" Ver todos sus productos" CommandName="VerArticulosD
</ItemTemplate>
</asp:DataList>
</asp:Content>
Partial Class tiendas4
Inherits System.Web.UI.Page
Protected Sub DataListTiendas_ItemComman
If e.CommandName = "VerArticulosDelCliente" Then
Dim strCodigoTienda As String = Trim(e.CommandArgument)
Session("IdTienda") = strCodigoTienda
Response.Redirect("Default
End If
End Sub
End Class
THIS VERSION DON0T WORK IY NEED THE BUTTON REDIRECT TO ANOTHER PAGE.
THIS OTHER VERSION WITOUT MASTER PAGE WORKS
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="tiendas3.aspx.vb
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div id="contenido2">
<asp:SqlDataSource ID="SqlDataSourceTiendas" runat="server"
ConnectionString="<%$ ConnectionStrings:Connecti
SelectCommand="SELECT Member_Id, IdTienda, Nombre_Fiscal, Nombre_Comercial, Lema, Persona_Contacto, Calle, CodPostal, CodProvincia, Poblacion, email, web, Telefono, Fax, logo, activo FROM Tiendas"></asp:SqlDataSour
<asp:DataList ID="DataListTiendas" runat="server" DataKeyField="IdTienda"
DataSourceID="SqlDataSourc
<ItemTemplate>
<span class="tienda_nombre"><asp
<asp:Button ID="Button2" runat="server" Text=" Ver todos sus productos" CommandName="VerArticulosD
</ItemTemplate>
</asp:DataList>
</form>
</body>
</html>
Partial Class tiendas3
Inherits System.Web.UI.Page
Protected Sub DataListTiendas_ItemComman
If e.CommandName = "VerArticulosDelCliente" Then
Dim strCodigoTienda As String = Trim(e.CommandArgument)
Session("IdTienda") = strCodigoTienda
Response.Redirect("Default
End If
End Sub
End Class
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER