Showing posts with label implement. Show all posts
Showing posts with label implement. Show all posts

Thursday, March 29, 2012

Passing Values Between web forms pages

i am trying to implement passing values from my login webpage to another. but i get an error of "Specified cast is not valid."

i followed the program logic and I cant find the error that the debugger says that it is in the casting. I am following the example provided by Microsoft in
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconpassingservercontrolvaluesbetweenpages.asp

next, it is the code behind of both forms

1st webform

<---login.aspx---
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub
Public ReadOnly Property UserId() As String
Get
Return Trim(txtUser.Text)
End Get
End Property

Private Sub lnkLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lnkLogin.Click

Server.Transfer("secondForm.aspx")

end sub

<----secondForm.aspx---
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web

Imports System.Web.Security
Imports System.Web.UI

Public Class secondForm

Inherits System.Web.UI.Page

Public userLogin As login

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim blnAddinProgress As Boolean

Dim strUsername As String

If Not IsPostBack() Then

userLogin = CType(Context.Handler, login)

strUsername = userLogin.UserId

<-----
The error that i got from the debugger is "Specified cast is not valid."

following this message, Do i have to change the casting or is there another error or piece of code that i am forgetting.

thanks in advanceYou might try the similar technique documented in this topic:

Passing Values Between Web Forms Pages
HI! the link that you provided me is the one that i used.

If you see the structure of the code is pretty simmilar to the one of the link. Do you know about other option?
the error could be related to I am using Forms authentications?

thank you very much for your help
>HI! the link that you provided me is the one that i used.

Ok. The URL that you provided is not the same as the one for the other article, so I was a little confused.

Here's a question: what kind of control is lnkLogin in your login page? It should be a LinkButton or just Button (not a Hyperlink).

So, assuming that you're using a LinkButton, the bad news is that I cannot reproduce your error. I had to add a line (which you probably have). This is what my target page code looks like:

 Public userLogin As login
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim blnAddinProgress As Boolean
Dim strUsername As String
If Not IsPostBack() Then
userLogin = CType(Context.Handler, login)
strUsername = userLogin.UserId
Response.Write(strUsername)
End If
End Sub

Wednesday, March 21, 2012

Passport Authentication in ASP.NET

Hi All,

I want to implement the .Net Passport Authentication in my ASP.NET web
application.

I have installed the Microsoft Passport SDK 2.5 on my machine. I have
also registered my profile (email address and company profile) while
downloading the Passport SDK.

I have not yet received the SiteID and the Key from Microsoft for
registering my Web Application for Passport Authentication.

I want to know the further steps involved in implementing the Passport
Authentication.

Can anyone help me?

Thanks in advance.

SudhirGo back to the Passport site and find an email for a contact person. I had
to do this with MapPoint .NET (now MapPoint Web Service) to speed up the
process.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
Author: ADO.NET and XML: ASP.NET on the Edge

************************************************** **************************
****
Think Outside the Box!
************************************************** **************************
****
"Sudhir Pai" <sudhir_pai@.rediffmail.com> wrote in message
news:8883ea5a.0307062137.48cc1141@.posting.google.c om...
> Hi All,
> I want to implement the .Net Passport Authentication in my ASP.NET web
> application.
> I have installed the Microsoft Passport SDK 2.5 on my machine. I have
> also registered my profile (email address and company profile) while
> downloading the Passport SDK.
> I have not yet received the SiteID and the Key from Microsoft for
> registering my Web Application for Passport Authentication.
> I want to know the further steps involved in implementing the Passport
> Authentication.
> Can anyone help me?
> Thanks in advance.
> Sudhir