whize13 Posted May 14, 2014 at 11:12 AM Report #555580 Posted May 14, 2014 at 11:12 AM Boas, eu tenho um uma dropdownlist e com 4 itens a qual a cada um atribui um valor. e gostava de passar essa valor para um modulo e como sou novo com o Web developer e nesta linguagem não estou a conseguir.
nelsonr Posted May 14, 2014 at 11:25 AM Report #555587 Posted May 14, 2014 at 11:25 AM Boas, podes usar a propriedade SelectedValue da dropdown para retornar qual o item selecionado
whize13 Posted May 14, 2014 at 01:31 PM Author Report #555600 Posted May 14, 2014 at 01:31 PM Eu já tentei mas no modulo eu escrevo a DDL e não me é reconhecida por isso é que estou co problema
nelsonr Posted May 14, 2014 at 01:37 PM Report #555601 Posted May 14, 2014 at 01:37 PM A dropdown pertence à página, por isso não terás acesso diretamente de outro sitio. O que pretendes fazer exactamente no modulo? Podes é chamar uma função do modulo e passas por parametro o valor selecionado da dropdown
whize13 Posted May 14, 2014 at 01:46 PM Author Report #555606 Posted May 14, 2014 at 01:46 PM A DropDown tem 4 itens: DT's Professores Alunos e Enc. Edu a qual tem o valor 0,1,2 e 3 respectivamente associados. Depois queria passar um desses valores dependendo do tipo de acesso escolhido para depois no modulo fazer a consulta certa a tabela na BD. o Codigo no ASPX é o seguinte: <%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="PaginaLogin.aspx.vb" Inherits="PAPWEB.PaginaLogin" %> <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server"> </asp:Content> <script runat="server"> Private Sub SaberAcesso() If Ddl.SelectedItem.Value = 0 Then lblPass.Visible = True lblTurma.Visible = True lblUser.Visible = True txbPass.Visible = True txbUser.Visible = True Label1.Visible = True btnLogin.Visible = True tbxTurma.Visible = True Else lblPass.Visible = True lblTurma.Visible = False lblUser.Visible = True txbPass.Visible = True txbUser.Visible = True tbxTurma.Visible = False Label1.Visible = False btnLogin.Visible = True End If End Sub </script> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <p> Escolha o tipo de acesso que pretende ter: <asp:DropDownList ID="Ddl" runat="server" > <asp:ListItem Text ="Diretor de Turma" Value ="0"></asp:ListItem> <asp:ListItem Text="Professor" Value="1"></asp:ListItem> <asp:ListItem Text="Aluno" Value="2" ></asp:ListItem> <asp:ListItem Text="Enc. Educação" Value="3"></asp:ListItem> </asp:DropDownList> <asp:Button ID="bttEscolher" runat="server" Text="Escolher" onclick="SaberAcesso" /> </p> <p> <asp:Label ID="lblUser" runat="server" Text="Utilizador:"></asp:Label> <asp:Textbox ID="txbUser" runat="server" ></asp:Textbox> </p> <p> <asp:Label ID="lblPass" runat="server" Text="Password:"></asp:Label> <asp:Textbox ID="txbPass" runat="server" ></asp:Textbox> </p> <p> <asp:Label ID="lblTurma" runat="server" Text="Turma:"></asp:Label> <asp:TextBox ID="tbxTurma" runat="server"></asp:TextBox> <asp:Label ID="Label1" runat="server" Text="Ex: 12º8"></asp:Label> </p> <asp:Button ID="btnLogin" runat="server" Text="Entrar" onclick="SaberAcesso" /> </asp:Content> Peço desculpa se estou a cometer erros basicos mas estou masi habituado ao Visual Basic e asp nao pesco muito.
nelsonr Posted May 14, 2014 at 01:57 PM Report #555610 Posted May 14, 2014 at 01:57 PM Ai na Sub SaberAcesso, chamas a função do modulo e passas por parametro o DDL.SelectedValue
whize13 Posted May 14, 2014 at 02:07 PM Author Report #555613 Posted May 14, 2014 at 02:07 PM Ele nao me reconhece o modulo na parte do ASPX eu pois coisa tipo isto <%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="PaginaLogin.aspx.vb" Inherits="PAPWEB.PaginaLogin" %> <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server"> </asp:Content> <script runat="server"> Private Sub SaberAcesso() If Ddl.SelectedItem.Value = 0 Then lblPass.Visible = True lblTurma.Visible = True lblUser.Visible = True txbPass.Visible = True txbUser.Visible = True Label1.Visible = True btnLogin.Visible = True tbxTurma.Visible = True Else lblPass.Visible = True lblTurma.Visible = False lblUser.Visible = True txbPass.Visible = True txbUser.Visible = True tbxTurma.Visible = False Label1.Visible = False btnLogin.Visible = True End If dim x as integer = Ddl.selecteditem.value acesso(x) End Sub </script> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <p> Escolha o tipo de acesso que pretende ter: <asp:DropDownList ID="Ddl" runat="server" > <asp:ListItem Text ="Diretor de Turma" Value ="0"></asp:ListItem> <asp:ListItem Text="Professor" Value="1"></asp:ListItem> <asp:ListItem Text="Aluno" Value="2" ></asp:ListItem> <asp:ListItem Text="Enc. Educação" Value="3"></asp:ListItem> </asp:DropDownList> <asp:Button ID="bttEscolher" runat="server" Text="Escolher" onclick="SaberAcesso" /> </p> <p> <asp:Label ID="lblUser" runat="server" Text="Utilizador:"></asp:Label> <asp:Textbox ID="txbUser" runat="server" ></asp:Textbox> </p> <p> <asp:Label ID="lblPass" runat="server" Text="Password:"></asp:Label> <asp:Textbox ID="txbPass" runat="server" ></asp:Textbox> </p> <p> <asp:Label ID="lblTurma" runat="server" Text="Turma:"></asp:Label> <asp:TextBox ID="tbxTurma" runat="server"></asp:TextBox> <asp:Label ID="Label1" runat="server" Text="Ex: 12º8"></asp:Label> </p> <asp:Button ID="btnLogin" runat="server" Text="Entrar" onclick="SaberAcesso" /> </asp:Content> Acesso está no modulo como public sub e mesmo assim nao da
nelsonr Posted May 14, 2014 at 02:14 PM Report #555616 Posted May 14, 2014 at 02:14 PM Tens de por o nome do módulo. Ex: Module1.acesso(x)
whize13 Posted May 14, 2014 at 02:18 PM Author Report #555619 Posted May 14, 2014 at 02:18 PM Tentei da maneira que propos mas tambem não dá sugere para gerar a class.
nelsonr Posted May 14, 2014 at 02:20 PM Report #555620 Posted May 14, 2014 at 02:20 PM Como é que criaste o módulo? Não tem lá no inicio algo do tipo "Module Module1" ?
whize13 Posted May 14, 2014 at 02:26 PM Author Report #555621 Posted May 14, 2014 at 02:26 PM Os passos feitos?
nelsonr Posted May 14, 2014 at 02:36 PM Report #555623 Posted May 14, 2014 at 02:36 PM Não tem lá no inicio algo do tipo "Module Module1" ?
whize13 Posted May 14, 2014 at 02:40 PM Author Report #555625 Posted May 14, 2014 at 02:40 PM Não sei que onde está a dizer. O meu modulo chama-se ModuloAcesso mas não encontro nada parecido com ModuloAcesso.Acesso
nelsonr Posted May 14, 2014 at 02:47 PM Report #555629 Posted May 14, 2014 at 02:47 PM Tens um ficheiro chamado ModuloAcesso.vb, correcto? Se abrires o ficheiro, o que tens na primeira linha? Não é algo do tipo "Module ModuloAcesso" ? Tens a sub acesso dentro desse modulo, correcto?
whize13 Posted May 14, 2014 at 02:49 PM Author Report #555630 Posted May 14, 2014 at 02:49 PM Sim e o codigo no Modulo é o seguinte Imports System.Data.SqlClient Module ModuloAcesso Public ligacao As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Jorge\Desktop\LivroPonto\LivroPonto\PAPSQL_DADOS.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True") Public Sub Acesso() End Sub End Module
nelsonr Posted May 14, 2014 at 02:51 PM Report #555631 Posted May 14, 2014 at 02:51 PM Então e não consegues usar ModuloAcesso.Acesso a partir da outra página? Precisas é de colocar ai o Acesso a aceitar um parametro
whize13 Posted May 14, 2014 at 02:56 PM Author Report #555632 Posted May 14, 2014 at 02:56 PM Exacto, o ModuloAcesso.Acesso não é reconhecido na pagina do ASPX na parte do Script. Do genero Public Sub Acesso(Byval numero as integer) End Sub End Module
nelsonr Posted May 14, 2014 at 03:15 PM Report #555638 Posted May 14, 2014 at 03:15 PM (edited) Hmm, pode ser por usares isso dentro do script, normalmente uso codebehind Edited May 14, 2014 at 03:15 PM by nelsonr
whize13 Posted May 14, 2014 at 03:17 PM Author Report #555639 Posted May 14, 2014 at 03:17 PM Continua sem funcionar mesmo indicando que estou a espera de receber um valor o script desconhece o modulo. Não sei o que é codebehind
nelsonr Posted May 14, 2014 at 03:24 PM Report #555642 Posted May 14, 2014 at 03:24 PM Coloca la o metodo SaberAcesso no PaginaLogin.aspx.vb
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