Usuário com melhor resposta
panel some depois de postback

Pergunta
-
boa tarde!
eu tenho 2 panel no meu form, sendo um criado em tempo de execucao e outro não.
quando eu dou um click em um botao dentro desse segundo panel, apos o postback ele some da tela, só ficando o que criei dinamicamente. alguem tem ideia pq?
Darth Tsurth
Respostas
Todas as Respostas
-
-
Private Sub carrinho_compras_Init(sender As Object, e As System.EventArgs) Handles Me.Init PopulaCarrinho() End Sub Public Sub PopulaCarrinho() Dim carrinho As carrinho = Nothing If Session("CarrinhoId") Is Nothing Then carrinho = Fabrica.Criar() Session("CarrinhoId") = carrinho.ID Else carrinho = Fabrica.Buscar(Session("CarrinhoId")) End If If carrinho IsNot Nothing Then Dim counter As String = 0 Dim quantidade_total = carrinho.Total If quantidade_total = 0 Then updPanelCart.Visible = False lbl_carrinhovazio.Visible = True Panel31.Visible = False btn_finalizar.Visible = False End If Dim painel As New Panel painel.Controls.Add(New LiteralControl("<table border='0' width='100%' cellspacing='0' cellpadding='0' align='center' class='tableBox_shopping_cart main'>")) painel.Controls.Add(New LiteralControl("<tr>")) painel.Controls.Add(New LiteralControl("<td style='background-color:#af0505; color:#ffffff;font-size: 13px; line-height:25px;font-family: arial; font-weight:bold; text-transform:uppercase;' align='center' class='imagem'>produto</td>")) painel.Controls.Add(New LiteralControl("<td style='background-color:#af0505; color:#ffffff;font-size: 13px; line-height:25px;font-family: arial; font-weight:bold; text-transform:uppercase;' align='center' class='products'>descrição do produto</td>")) painel.Controls.Add(New LiteralControl("<td style='background-color:#af0505; color:#ffffff;font-size: 13px; line-height:25px;font-family: arial; font-weight:bold; text-transform:uppercase;' align='center' class='quantity'>quantidade</td>")) painel.Controls.Add(New LiteralControl("<td style='background-color:#af0505; color:#ffffff;font-size: 13px; line-height:25px;font-family: arial; font-weight:bold; text-transform:uppercase;' valign='middle' align='center' class='excluir'>excluir</td>")) painel.Controls.Add(New LiteralControl("<td style='background-color:#af0505; color:#ffffff;font-size: 13px; line-height:25px;font-family: arial; font-weight:bold; text-transform:uppercase;' align='center' class='total'>valor</td>")) painel.Controls.Add(New LiteralControl("</tr>")) For Each umItem As Item1 In carrinho.Items Dim lbl_titulo As New Label Dim imagem As New Image Dim lbl_descricao As New Label Dim lbl_valor As New Label Dim lbl_quantidade As New Label painel.Controls.Add(New LiteralControl("<tr><td style='background-color:#ededed' align='center' class='s_cart_td'><br>")) imagem.ImageUrl = umItem.Produto.Imagem_caminho imagem.Width = "100" imagem.Height = "70" painel.Controls.Add(imagem) painel.Controls.Add(New LiteralControl("</span></td>")) painel.Controls.Add(New LiteralControl("<td align='center' style='background-color:#ededed'><table cellpadding='0' cellspacing='10' border='0'><tr><td class='name name3_padd'><span class='productSpecialPrice'>")) lbl_titulo.Text = umItem.Produto.Nome painel.Controls.Add(lbl_titulo) painel.Controls.Add(New LiteralControl("</span> - R$")) Dim lblvalor As New Label lblvalor.Text = umItem.Produto.Valor painel.Controls.Add(lblvalor) painel.Controls.Add(New LiteralControl("</td></tr><tr><td style='width:100%;background-color:#ededed' align='center'><i>")) lbl_descricao.Text = umItem.Produto.Descricao painel.Controls.Add(lbl_descricao) painel.Controls.Add(New LiteralControl("</i></td></tr></table>")) painel.Controls.Add(New LiteralControl("</td><td align='center' style='background-color:#ededed' valign='middle'><br><br><br><br>")) Dim lbl_info As New Label Dim txtqtidade As New TextBox txtqtidade.Width = 25 txtqtidade.ID = "txtqtidade" + umItem.Produto.ID.ToString If txtqtidade.ID = "txtqtidade" + Session("recupera_id") Then txtqtidade.Text = 10 lbl_info.Text = "Quantidade máxima excedida por produto." Else txtqtidade.Text = umItem.Quantidade End If painel.Controls.Add(txtqtidade) painel.Controls.Add(New LiteralControl(" ")) Dim atualizaButton As New ImageButton atualizaButton.ID = "AtualizaButton" + counter.ToString() atualizaButton.ImageUrl = "images/btn_atualizar_carrinho.gif" atualizaButton.CommandArgument = umItem.Produto.ID AddHandler atualizaButton.Click, AddressOf AtualizarCarrinho counter += 1 painel.Controls.Add(atualizaButton) painel.Controls.Add(New LiteralControl("<br><font size=1")) painel.Controls.Add(lbl_info) painel.Controls.Add(New LiteralControl("<td style='background-color:#ededed' align='center'><br><br><br><br>")) Dim link As New ImageButton link.ID = "link" + umItem.Produto.ID.ToString link.ImageUrl = "images/btn_excluir.gif" link.CommandArgument = umItem.Produto.ID AddHandler link.Click, AddressOf ExcluirCarrinho painel.Controls.Add(link) painel.Controls.Add(New LiteralControl("</td><td align='center' style='background-color:#ededed' valign='middle' class='s_cart_td'><br><br><br><br><span class='productSpecialPrice'>R$ ")) Dim quantidade As Integer = txtqtidade.Text Dim soma As Decimal = umItem.Produto.Valor * quantidade lbl_valor.Text = soma painel.Controls.Add(lbl_valor) painel.Controls.Add(New LiteralControl("</td></tr>")) Panel1.Controls.Add(painel) painel.Controls.Add(New LiteralControl("</td></tr>")) painel.Controls.Add(New LiteralControl("<tr><td colspan='5' style='background-color:#ededed' align='center'><img src='images/barra_carrinho.jpg'></td></tr>")) Dim trigger As New AsyncPostBackTrigger() trigger.ControlID = atualizaButton.ID trigger.EventName = "Click" updPanelCart.Triggers.Add(trigger) Next End If End Sub Protected Sub lnk_cep_Click(sender As Object, e As EventArgs) Handles lnk_cep.Click Panel_info_frete.Visible = True frete() End Sub
<asp:UpdatePanel ID="updPanelCart" runat="server">
<ContentTemplate>
<asp:Panel ID="Panel1" runat="server">
</asp:Panel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btn_continuar" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<asp:Panel ID="Panel31" runat="server" Width="100%">
<table border="0" bgcolor="#cdcdcd" width="100%" cellspacing="0" cellpadding="0" align="center" class="tableBox_shopping_cart main">
<tr>
<td bgcolor="#f3ede3"></td>
<td align="right" bgcolor="#f3ede3">
<br />
Subtotal:</td>
<td bgcolor="#f3ede3" align="center">
<span class="style64"><strong>
<br />
R$ </strong></span>
<asp:Label ID="lbl_sub" runat="server"
style="font-size: small; font-weight: 700"></asp:Label></td>
</tr>
<tr>
<td bgcolor="#f3ede3" align="right" class="style116">
<asp:Panel ID="Panel4" runat="server" Width="691px">
</asp:Panel>
</td>
<td bgcolor="#f3ede3" align="right" class="style99">
</td>
<td bgcolor="#f3ede3" class="style120">
</td>
</tr>
<tr>
<td align="right" class="style116">
<br style="font-size:2pt" />
<strong>Informe o CEP de entrega para calcular frete: </strong> <asp:TextBox
ID="txt_cep1" runat="server" Width="75px"></asp:TextBox>
-<asp:TextBox ID="txt_cep2" runat="server" Width="42px"></asp:TextBox>
<asp:LinkButton ID="lnk_cep" runat="server">Buscar</asp:LinkButton>
<br style="font-size:2pt" /><br style="font-size:2pt" />
</td>
<td align="right" class="style99">
<br style="font-size:2pt" />
<asp:Label ID="lbl_frete" runat="server" Text="Frete:" Visible="true"></asp:Label>
<br style="font-size:2pt" />
</td>
<td class="style120" align="center">
<br style="font-size:2pt" />
<strong><asp:Label ID="lbl_rs" runat="server" style="font-size: small"
Text="R$" Visible="False"></asp:Label></strong><asp:Label ID="ft_preco" runat="server" style="font-size: small; font-weight: 700;"></asp:Label>
<br style="font-size:2pt" />
</td>
</tr>
</table>
<br />
<asp:Panel ID="Panel_info_frete" runat="server" Visible="false" Width="918px">
<table align="center" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="style122">
Tipo de entrega:
<asp:Label ID="lbl_tipo" runat="server" CssClass="style121"></asp:Label>
<br />
Entrega em
<asp:Label ID="lbl_dias" runat="server" CssClass="style121"></asp:Label>
dias úteis<br />
<asp:Label ID="lbl_erro" runat="server" CssClass="style78"></asp:Label>
</td>
<td class="style76" align="center">
<strong>
<asp:Label ID="lbl_selecione_frete0" runat="server"
Text="Selecione uma opção de frete:"></asp:Label>
<asp:RadioButtonList ID="radio_cep" runat="server" AutoPostBack="True"
Font-Size="X-Small" RepeatDirection="Horizontal" Width="133px">
<asp:ListItem Selected="True" Value="40010">Sedex</asp:ListItem>
<asp:ListItem Value="41106">Pac</asp:ListItem>
</asp:RadioButtonList>
</strong>
</td>
</tr>
</table>
</asp:Panel>
<br /><br />
<table bgcolor="#af0505">
<tr>
<td class="style123">
<br style="font-size:2pt" />
<strong> Valor Total: </strong>
<br style="font-size:2pt" />
</td>
<td>
<br style="font-size:2pt" />
<strong><span class="style124">R$</span> </strong>
<asp:Label ID="lbl_total" runat="server"
style="font-size: small; font-weight: 700; color: #FFFFFF;"></asp:Label>
<br style="font-size:2pt" /><br style="font-size:2pt" />
</td>
</tr>
</table>
</asp:Panel>
o problema acontece quando eu clico no botao Lnk_cep, qualquer funcao que eu der no click desse botao ele some com o panel31.Darth Tsurth
-
No seu botão lnk_cep, eis o código:
Protected Sub lnk_cep_Click(sender As Object, e As EventArgs) Handles lnk_cep.Click Panel_info_frete.Visible = True frete() End Sub
Essa função frete, o que ela faz? ela não está presente no código...
Ao infinito e além!
-
nada que atrapalhe o postback, pois mesmo sem chamar esse frete() ele da o mesmo erro, só o click do botão, fazendo o postback ele faz sumir o panel
Protected Sub frete() Dim tipo = Session("tipo_frete") Dim cep_origem = Session("cep_destino") Dim cep_destino = Session("cep_destino") Dim nCdEmpresa As String = String.Empty Dim sDsSenha As String = String.Empty ' Código do tipo de frete Dim nCdServico As String = tipo ' Cep de origem e destino - apenas números Dim sCepOrigem As String = cep_origem Dim sCepDestino As String = cep_destino ' Peso total da encomenda - por padrão deixei 1kg Dim nVlPeso As String = "1" ' Formato da encomenda - por padrão deixei caixa Dim nCdFormato As Integer = 1 ' Para encomenda do tipo PAC, deve-se preencher a dimensão da embalagem Dim nVlComprimento As Decimal = 20 Dim nVlAltura As Decimal = 20 Dim nVlLargura As Decimal = 20 Dim nVlDiametro As Decimal = 0 ' Informa se é por mão própria - por padrão deixei Não Dim sCdMaoPropria As String = "N" ' Valor declarado - por padrão não informo Dim nVlValorDeclarado As Decimal = 0 ' Se desejo recebr aviso de recebimento - por padrão não quero Dim sCdAvisoRecebimento As String = "N" ' Instancio o web-service Dim webServiceCorreios As New Correios.CalcPrecoPrazoWSSoapClient() ' Efetuo a requisição Dim retornoCorreios As Correios.cResultado = webServiceCorreios.CalcPrecoPrazo(nCdEmpresa, sDsSenha, nCdServico, sCepOrigem, sCepDestino, nVlPeso, _ nCdFormato, nVlComprimento, nVlAltura, nVlLargura, nVlDiametro, sCdMaoPropria, nVlValorDeclarado, sCdAvisoRecebimento) ' Verifico se há retorno If retornoCorreios.Servicos.Length > 0 Then ' Se deu tudo certo, então retorna o valor If retornoCorreios.Servicos(0).Erro = "0" Then ft_preco.Text = retornoCorreios.Servicos(0).Valor lbl_dias.Text = retornoCorreios.Servicos(0).PrazoEntrega If tipo = "40010" Then lbl_tipo.Text = "SEDEX" ElseIf tipo = "41106" Then lbl_tipo.Text = "PAC" End If Dim compras As Decimal = hidden2.Value Dim frete As Decimal = ft_preco.Text lbl_total.Text = compras + frete Else lbl_erro.Text = retornoCorreios.Servicos(0).MsgErro End If Else lbl_erro.Text = "NÃO FOI POSSÍVEL CONSULTAR O SERVIÇO DESEJADO!" End If End Sub
Darth Tsurth
-