PDA

View Full Version : How do I get a ASPX variable value to AspX.vb Sub?


Buzzmaster
09-22-2007, 03:52 AM
Typically, you will be handling the event OnAuthenticte to "grab" what the user inputted for the LoginName.
This would be an example of your login control on the asp page.

<asp:Login ID="Login1" runat="server" OnAuthenticate="Login1_Authenticate"></asp:Login>

If you notice, the important thing to take away from this small bit of code is the OnAuthenticate attribute of the asp:Login control.

In the code behind, or nested in the <script> if you are not using code behinds, you will need to create a method to "Handle" the onAuthenticate event like so;
C#



[quote]

protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
{
string user = Login1.UserName;
}</CODE>
VB

[quote]

Protected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As AuthenticateEventArgs)
Dim user As String = Login1.UserName
End Sub </CODE>


As you can see the "UserName" property of the Login control will give you the user name that the user inputted.

BZ

BillAndrews
09-22-2007, 04:01 AM
I used this code and it worked fine. Thanks much.


strMsg = "UserName = " &amp; User.Identity.Name &amp; vbCrLf

BillAndrews
09-22-2007, 12:58 PM
How do I get a ASPX variable value to AspX.vb Sub? I a LoginUser control on the page
and I have a Submit Sub in the aspx.vb code. I want the value of the LoginName1. I've
tried different methods but nothing I've tried works.

example strMsg = "UserName = " &amp; LoginName1