473,395 Members | 1,571 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Pass parameters to the code behind.

Hello.

In Visual Studio 2008,
there is on the toolbox -login -login,
which create a login form.

On that form there is a LoginButton, which click on it is evented on the
"default.aspx.vb" codeBehind.

How can I use the value on the codeBehind (default.aspx.vb) of UserName &
Password that are on "default.aspx" ?

Thanks :)
Oct 13 '08 #1
5 2526
You can use the UserName and Password properties if you meant you would like
to read those values ("use" is pretty vague). You could use the authenticate
event if you are trying to implement a custom authentication scheme.

Also make sure you checked the documentation before posting :
http://msdn.microsoft.com/en-us/libr...ols.login.aspx

--
Patrice
"Mr. X." <no_spam_please@nospam_please.coma écrit dans le message de
groupe de discussion : eS**************@TK2MSFTNGP03.phx.gbl...
Hello.

In Visual Studio 2008,
there is on the toolbox -login -login,
which create a login form.

On that form there is a LoginButton, which click on it is evented on the
"default.aspx.vb" codeBehind.

How can I use the value on the codeBehind (default.aspx.vb) of UserName &
Password that are on "default.aspx" ?

Thanks :)
Oct 13 '08 #2
The "code behind" cannot use the UserName nor the Password as it.
Maybe via request.something ?

Here is the code (that automatically generated by VS 2008) :
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Login.aspx.vb"
Inherits="CSMManager._Default" %>

<!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>Untitled Page</title>

<style type="text/css">

#Text1

{

width: 248px;

margin-right: 31px;

}

#Text2

{

width: 247px;

margin-right: 31px;

}

</style>

</head>

<body>

<form id="form1" runat="server">

<asp:Login ID="Login1" runat="server" Width="395px">

<LayoutTemplate>

<table align="right" border="0" cellpadding="1" cellspacing="0" dir="rtl"

style="border-collapse:collapse;">

<tr>

<td>

<table border="0" cellpadding="0">

<tr>

<td align="center" colspan="2">

Connect~</td>

</tr>

<tr>

<td align="right">

<asp:Label ID="UserNameLabel" runat="server"
AssociatedControlID="UserName">User Name:</asp:Label>

</td>

<td>

<asp:TextBox ID="UserName" runat="server"></asp:TextBox>

<asp:RequiredFieldValidator ID="UserNameRequired" runat="server"

ControlToValidate="UserName" ErrorMessage="User Name is required."

ToolTip="User Name is required."
ValidationGroup="Login1">*</asp:RequiredFieldValidator>

</td>

</tr>

<tr>

<td align="right">

<asp:Label ID="PasswordLabel" runat="server"
AssociatedControlID="Password">Password:</asp:Label>

</td>

<td>

<asp:TextBox ID="Password" runat="server" TextMode="Password"></asp:TextBox>

<asp:RequiredFieldValidator ID="PasswordRequired" runat="server"

ControlToValidate="Password" ErrorMessage="Password is required."

ToolTip="Password is required."
ValidationGroup="Login1">*</asp:RequiredFieldValidator>

</td>

</tr>

<tr>

<td colspan="2">

<asp:CheckBox ID="RememberMe" runat="server"

Text="remember password" />

</td>

</tr>

<tr>

<td align="center" colspan="2" style="color:Red;">

<asp:Literal ID="FailureText" runat="server"
EnableViewState="False"></asp:Literal>

</td>

</tr>

<tr>

<td align="right" colspan="2">

<asp:Button ID="LoginButton" runat="server" CommandName="Login"

onclick="LoginButton_Click" Text="Connect" ValidationGroup="Login1"

style="height: 26px" />

</td>

</tr>

</table>

</td>

</tr>

</table>

</LayoutTemplate>

</asp:Login>

</form>

</body>

</html>

In CodeBehind : "Login.aspx.vb"

==========================

Imports System.Data.OleDb

Partial Public Class _Default

Inherits System.Web.UI.Page

Protected Sub LoginButton_Click(ByVal sender As Object, ByVal e As
EventArgs)

Dim s As String

MsgBox(UserName.text)

....

End Sub

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Handles Me.Load

End Sub

End Class

What should I put instead of the line MsgBox(UserName.text) ?

Thanks :)
Oct 14 '08 #3
Have you tried Login1.UserName and Login1.Password ?

--
Patrice


Oct 14 '08 #4
Yes, that works.

I don't understand why cannot I use
UserName (It has an ID),
but I should Use Login1.UserName ?

Thanks :)
Oct 14 '08 #5
Hi,

Have a look to User.Identity.IsAuthenticated

http://msdn.microsoft.com/en-us/libr...er(VS.71).aspx

If that is to difficult use the normal session to save those (as it was done
in past)

Cor
"Mr. X." <no_spam_please@nospam_please.comschreef in bericht
news:eS**************@TK2MSFTNGP03.phx.gbl...
Hello.

In Visual Studio 2008,
there is on the toolbox -login -login,
which create a login form.

On that form there is a LoginButton, which click on it is evented on the
"default.aspx.vb" codeBehind.

How can I use the value on the codeBehind (default.aspx.vb) of UserName &
Password that are on "default.aspx" ?

Thanks :)

Oct 14 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Zlatko Matić | last post by:
Let's assume that we have a database on some SQL server (let it be MS SQL Server) and that we want to execute some parameterized query as a pass.through query. How can we pass parameters to the...
0
by: Zlatko Matić | last post by:
Hi everybody! Recently I was struggling with client/server issues in MS Access/PostgreSQL combination. Although Access is intuitive and easy to use desktop database solution, many problems...
9
by: Frank Rizzo | last post by:
I've got a number of user controls on the web page. How can I pass some data to it? I don't see where the user control is instantiated in the page code-behind page. Thanks.
4
by: Rod | last post by:
I've got 2 ASP.NET WebPages that I've written in VB.NET 2003. One of them has several controls on it, including at the bottom of the page an IFrame. The second ASP.NET page is supposed to have...
12
by: Phil Certain | last post by:
Hi, I'm trying to do something very simple...or at least it should be. I have created a host page (gen.aspx) and a very simple user control (us.ascx). The corresponding code-behind files are...
2
by: phil | last post by:
Hi, I want to put a recordset in a gridview but i don't know how to pass the value of the variable in the 'where' statement. The value of the variable is set in the code-behind. i added a tag...
5
by: slowmotiongenius | last post by:
All- I have established an adodb recordset in my code-behind, and I need to pass it to the aspx file. I can't seem to figure out if there is a way to do this. I see you can pass a string over...
1
by: peridian | last post by:
This is more of a general question, but I didn't know where to post it. Since Java is an example of a language which does this, I thought here would work. Coming from a C++ background, having...
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.