|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Problem with FindControlwithin a login view (lv1) using the following code but each of the 2 Dim statements get flagged with"End of Statement expected"? What is the correct way to do this? ============================= Protected Sub Login1_LoginError(ByVal sender As Object, ByVal e As System.EventArgs) Dim currlogin As Login = lv1.FindControl("Login1") as Login Dim membername As String = currlogin.FindControl("UserName") as String If membername.IsApproved Then Exit Sub Else 'User Not Yet Approved currlogin.FailureText = "User has not been authorized yet." End If End Sub C# has 'as' keyword for trycasting, In VB2005 same is TryCast.
Dim currlogin As Login = TryCast(lv1.FindControl("Login1"), Login) If Not IsNothing(currLogin) Then 'Access Login object here End If Show quoteHide quote "Wayne Wengert" <wayneSKIPSPAM@wengert.org> wrote in message news:O6dS52rIGHA.1848@TK2MSFTNGP12.phx.gbl... >I am attempting to check the status of a login (Login1) which is containted >within a login view (lv1) using the following code but each of the 2 Dim >statements get flagged with"End of Statement expected"? What is the correct >way to do this? > > ============================= > Protected Sub Login1_LoginError(ByVal sender As Object, ByVal e As > System.EventArgs) > > Dim currlogin As Login = lv1.FindControl("Login1") as Login > > Dim membername As String = currlogin.FindControl("UserName") as String > > If membername.IsApproved Then > > Exit Sub > > Else 'User Not Yet Approved > > currlogin.FailureText = "User has not been authorized yet." > > End If > > End Sub > > Wayne,
Controls are cool but here's easier way to check if a user is logged in. It also works on pages without login controls incase you have a seperate login page. If Page.User.Identity.IsAuthenticated Then label1.text = "Welcome " & Page.User.Identity.Name else label1.text = "User not authorized, you need to sign in" End If Good Luck DWS Show quoteHide quote "Wayne Wengert" wrote: > I am attempting to check the status of a login (Login1) which is containted > within a login view (lv1) using the following code but each of the 2 Dim > statements get flagged with"End of Statement expected"? What is the correct > way to do this? > > ============================= > Protected Sub Login1_LoginError(ByVal sender As Object, ByVal e As > System.EventArgs) > > Dim currlogin As Login = lv1.FindControl("Login1") as Login > > Dim membername As String = currlogin.FindControl("UserName") as String > > If membername.IsApproved Then > > Exit Sub > > Else 'User Not Yet Approved > > currlogin.FailureText = "User has not been authorized yet." > > End If > > End Sub > > >
These controls are a real mess
DataSourceID '<NewDataSource ...>' not working in composite contro Global Themes Folder Missing How to turn off padding within a Web Part? .NET multi-column listbox for webpages? Gridview not updating database row Hide show asp table TreeView Security error DropDown List Script edit server control |
|||||||||||||||||||||||