Boas pessoal.
Estou a procura de um toturial com código comentado, sobre a criação de uma enquete qualquer. Alguem poderia me ajudar?
Encontro em ASP, em PHP..mas não vejo em ASP.NET
Tutorial De Enquete
Started By Lengrat, 26/07/2004, 20:33
4 replies to this topic
#1
Posted 26/07/2004, 20:33
#2
Posted 26/07/2004, 22:58
Olá Lengrat,
eu também já procurei muito na net sobre tutoriais ou artigos sobre como fazer uma enquete em asp.net, realmente só achei uma, muito boa até, que resolveu meu problema...estou sem o link em mãos, mas se você for ao site da MSDN Brasil, na seção artigos ou tutorias, escreva "enquete", na busca, que você irá achar!
Abraços,
Leonardo Hickstein
Hickstein Lab
eu também já procurei muito na net sobre tutoriais ou artigos sobre como fazer uma enquete em asp.net, realmente só achei uma, muito boa até, que resolveu meu problema...estou sem o link em mãos, mas se você for ao site da MSDN Brasil, na seção artigos ou tutorias, escreva "enquete", na busca, que você irá achar!
Abraços,
Leonardo Hickstein
Hickstein Lab
#3
Posted 26/07/2004, 23:51
uhauhauha eu havia postado lá essa mesma dúvida. Será que você é a mesma pessoa que me respondeu? hehe em se Julgar pelo Hicksteinlab, acho que eh você sim, Leonardo
mas não encontrei não. Só encontrei em ASP.
mas não encontrei não. Só encontrei em ASP.
Edição feita por: Lengrat, 26/07/2004, 23:53.
#4
Posted 27/07/2004, 11:09
Bem..eu de novo aqui
Hick, aquele que você me mostrou lá no fórum do MSDN Brasil é interessante, só que ele não armazena o IP. Se eu fechar o navegador e voltar para a enquete, eu posso votar quantas vezes quiser.
Em ASP eu encontrei algo mais simples, que é perfeito
Como é que eu faço para migrar este código para ASP.NET?
Hick, aquele que você me mostrou lá no fórum do MSDN Brasil é interessante, só que ele não armazena o IP. Se eu fechar o navegador e voltar para a enquete, eu posso votar quantas vezes quiser.
Em ASP eu encontrei algo mais simples, que é perfeito
<% 'Two varibles are passed into the db 'u_input is the value if the user entered a response to 'the vote/poll question....IP is the address of the user u_input=request.form("u_input") u_ip=request.servervariables("remote_addr") ' if the user did not enter anything in the poll on this visit ' then display the poll question and possible choices if u_input = "" then %> <form method="post" action="<%= request.servervariables("script_name") %>"> <p>Question Goes Here<br> <input type="radio" value="1" name="u_input">A<br> <input type="radio" value="2" name="u_input" >B<br> <input type="radio" value="3" name="u_input" checked>C<br> <input type="radio" value="4" name="u_input">D<br> <input type="submit" value="Submit" ></p> </form> <% else ' if the user did input a choice on the vote/ballot ' check to see if their ip address is already in the db cn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\web\arte4u\dados\votes_db.mdb" set rs = server.createobject("ADODB.Recordset") sql = "select ip from ballot where ip ='" & u_ip & "'" rs.Open sql, cn if rs.eof then ' if the user has not voted previously indicate it been_here_before="No" end if rs.close if been_here_before = "No" then ' Since the user has not voted previously their input ' their vote will be added to the db sql = "insert into ballot (ip, selection" & u_input &") " sql = sql & "values ('" & u_ip & "',1)" rs.Open sql, cn end if 'This will summerize and count the records in the db sql= "select distinctrow sum(selection1) as sum_selection1, " sql= sql & "sum(selection2) AS sum_selection2, sum(selection3) AS sum_selection3, " sql= sql & "sum(selection4) AS sum_selection4, count(*) AS total_votes " sql= sql & "FROM ballot;" rs.Open sql, cn total1=rs ("sum_selection1") total2=rs ("sum_selection2") total3=rs ("sum_selection3") total4=rs ("sum_selection4") count=rs ("total_votes") %> <br> A<img src="red.jpg" height="10" width="<%= (total1/count)*100 %>"> <%= formatnumber((total1/count)*100,1) %>%<br> B<img src="yellow.jpg" height="10" width="<%= (total2/count)*100 %>"> <%= formatnumber((total2/count)*100,1) %>%<br> C<img src="green.jpg" height="10" width="<%= (total3/count)*100 %>"> <%= formatnumber((total3/count)*100,1) %>%<br> D<img src="blue.jpg" height="10" width="<%= (total4/count)*100 %>"> <%= formatnumber((total4/count)*100,1) %>%<br> Total Votes: <%= formatnumber(count,0,0) %><br> <% if been_here_before <> "No" then %> This user has voted before and this one was <u>not</u> counted..... <% else %> This user has <u>not</u> voted before and this one was counted..... <% end if %> <br> The I.P. Address is <%= u_ip %> <% end if %>
Como é que eu faço para migrar este código para ASP.NET?
#5
Posted 27/07/2004, 13:52
Olá Claudio,
te aconselho o seguinte, você pode usar aquele código da enquete no site da MSDN, e gravar o been_here_before em um cookie que expira em 24hrs ou então gravar ou modificar no banco para "yes"...
Espero ter ajudado,
Leonardo Hickstein
Hickstein Lab
te aconselho o seguinte, você pode usar aquele código da enquete no site da MSDN, e gravar o been_here_before em um cookie que expira em 24hrs ou então gravar ou modificar no banco para "yes"...
Espero ter ajudado,
Leonardo Hickstein
Hickstein Lab
0 user(s) are reading this topic
0 membro(s), 0 visitante(s) e 0 membros anônimo(s)