Leudassdf Posted April 26, 2013 at 10:16 PM Report #504971 Posted April 26, 2013 at 10:16 PM Boas pessoal, eu tenho o seguinte código: <asp:ImageButton ID="img_like" runat="server" Height="48px" Visible="False" Width="48px" ImageUrl='<%# Eval("gosto", "~\Imagens\Like_dontlike\{0}.png") %>' /> No entanto o que eu quero é que o programa só execute este pedaço de código caso o session("tipo")="1" A linguagem de programação é ASP VB
Rechousa Posted April 27, 2013 at 12:21 AM Report #504982 Posted April 27, 2013 at 12:21 AM Olá, Na realidade o teu código não faz nada, já que e imagem está escondida (visible = false). O que é que pretendes fazer quando o session("tipo") = 1 e diferente de 1 ? Pedro Martins Sharing is Knowledge! http://www.linkedin.com/in/rechousa
Leudassdf Posted April 27, 2013 at 10:14 PM Author Report #505022 Posted April 27, 2013 at 10:14 PM Olá, Na realidade o teu código não faz nada, já que e imagem está escondida (visible = false). O que é que pretendes fazer quando o session("tipo") = 1 e diferente de 1 ? Boas, o objectivo era criar a image button apenas quando o session("tipo") fosse 1.ou seja quando fosse outro valor o image button nao era criado.
Rechousa Posted April 27, 2013 at 10:33 PM Report #505024 Posted April 27, 2013 at 10:33 PM Ok, então fazes o seguinte: protected void Page_PreRender(object sender, EventArgs e) { img_like.Visible = Session["tipo"] == "1"; } Pedro Martins Sharing is Knowledge! http://www.linkedin.com/in/rechousa
Leudassdf Posted April 27, 2013 at 11:19 PM Author Report #505026 Posted April 27, 2013 at 11:19 PM Ok, então fazes o seguinte: protected void Page_PreRender(object sender, EventArgs e) { img_like.Visible = Session["tipo"] == "1"; } O problema é que o img_like deveria ter um databinding de maneira a saber qual é o valor que vinha da variável favoritos, da query á qual me ajudou a resolver o problema, só se eu consegui-se inicialmente quando carrego a página, ainda sem fazer o login, o img_like não tinha databinding, só passaria a ter quando fize-se login. não sei se funcionará. mas vou tentar...
passarito Posted April 30, 2013 at 08:16 AM Report #505278 Posted April 30, 2013 at 08:16 AM (edited) Tenta isto <% If session("tipo")="1" then %> O que tu quizeres em HMTL ou outro <% else %> O que tu quizeres em HMTL ou outro <% end if %> Nota: - Se não tiver else tens de colocar na mesma o end if - Verifica se o 1 é texto ou numérico. É que se for numérico não leva aspas ficará assim: <% If session("tipo")=1 then %> Edited April 30, 2013 at 08:18 AM by passarito
Leudassdf Posted May 1, 2013 at 06:45 PM Author Report #505488 Posted May 1, 2013 at 06:45 PM Tenta isto <% If session("tipo")="1" then %> O que tu quizeres em HMTL ou outro <% else %> O que tu quizeres em HMTL ou outro <% end if %> Nota: - Se não tiver else tens de colocar na mesma o end if - Verifica se o 1 é texto ou numérico. É que se for numérico não leva aspas ficará assim: <% If session("tipo")=1 then %> Boas, Eu ja fiz isso anteriormente. Infelizmente nao funcionou
passarito Posted May 2, 2013 at 07:49 AM Report #505554 Posted May 2, 2013 at 07:49 AM (edited) Não faz o if ou não faz o else? Verifica o que ele escreve. Cá para mim a variável tipo não tem qualquer valor... Antes deste código manda escrever a varável tipo. respond.write(session("tipo")) Se ele retornar 1 e fizer o else experimenta If session("tipo") = 1 then Edited May 2, 2013 at 07:50 AM by passarito
Leudassdf Posted May 2, 2013 at 06:40 PM Author Report #505634 Posted May 2, 2013 at 06:40 PM (edited) Não faz o if ou não faz o else? Verifica o que ele escreve. Cá para mim a variável tipo não tem qualquer valor... Antes deste código manda escrever a varável tipo. respond.write(session("tipo")) Se ele retornar 1 e fizer o else experimenta If session("tipo") = 1 then O problema era exatamente o valor. Já consegui. Obrigado Edited May 2, 2013 at 06:40 PM by Leudassdf
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now