|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread |
Rating:
|
Display Modes |
|
|
|
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#16
|
|||
|
|||
|
hi sir. I've tried looking at this but I don't seem to see any of this as the reason why I got this message. I am using dotnetnuke, a good cms. I created a custom module from the super simple DAL+ tutorial (you can check it out) it works smoothly. I had placed a script block in the .aspx code of my module that works. I THEN COMMENTED OUT ALL OTHER CODE IN THE .ASPX and .ASPX.VB codes except imports, header and end of class declaration, and the control directive.
e.g. in .aspx.vb code: imports ... imports... imports... imports... Partial Class Something Inherits Something End Class in .aspx code: <@control language="vb" ....................> <script> this is my working code that automatically logs in a user to dotnetnuke, from clicking a hyperlink from a main website. </script> ------------------------------------------------------------so that's what's left. THEN, I get the error when I click the Logout button from the dotnetnuke website.... so sir, do you have any ideas? thanks for imparting your knowledge to a newbie. regards. |
|
#17
|
||||
|
||||
|
hello and welcome to aspfree.
if you want help, you'll have to post full error message and the relevant code. we don't have telepathic tiaras over here. |
|
#18
|
|||
|
|||
|
Quote:
good day sir, thanks for the prompt response! the error is the same name as the thread sir. "Object reference not set to an instance of an object error" the code I have posted the skeleton of it previously. the .aspx.vb code and the .aspx code. do you need the code itself? the explanation as well is in the previous post sir. |
|
#19
|
|||
|
|||
|
this is the original .aspx code:
Code:
<%@ Control Language="VB"
AutoEventWireup="false"
CodeFile="SuperSimple.ascx.vb"
Inherits="DesktopModules_SuperSimple_SuperSimple" %>
Search:
<asp:TextBox ID="txtSearch" runat="server"></asp:TextBox>
<asp:Button ID="btnSearch" runat="server" Text="Button" /><br />
<br />
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
this is the original .aspx.vb code:
Imports DotNetNuke
Imports System.Web.UI
Imports System.Collections.Generic
Imports System.Reflection
Imports DotNetNuke.Security.PortalSecurity
Partial Class DesktopModules_SuperSimple_SuperSimple
Inherits Entities.Modules.PortalModuleBase
Protected Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
ShowData("")
End If
End Sub
Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
ShowData(txtSearch.Text)
End Sub
Private Sub ShowData(ByVal SearchString As String)
Dim mySqlString As New StringBuilder()
mySqlString.Append("SELECT FriendlyName, Description ")
mySqlString.Append("FROM {databaseOwner}{objectQualifier}DesktopModules ")
mySqlString.Append("WHERE Description like '%' + @SearchString + '%' ")
mySqlString.Append("ORDER BY FriendlyName")
Dim myParam As SqlParameter = New SqlParameter("@SearchString", SqlDbType.VarChar, 150)
myParam.Value = SearchString
Me.GridView1.DataSource = CType(DataProvider.Instance().ExecuteSQL(mySqlStri ng.ToString(), myParam), IDataReader)
Me.GridView1.DataBind()
End Sub
End Class
THEN THIS IS WHAT'S LEFT: in the .aspx code: Code:
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="SuperSimple.ascx.vb" Inherits="DesktopModules_SuperSimple_SuperSimple" %> in the .aspx.vb code: next reply.... Last edited by nofriends : April 17th, 2007 at 05:04 AM. Reason: added [code][/code] tags |
|
#20
|
|||
|
|||
|
Code:
Imports DotNetNuke Imports System.Web.UI Imports System.Collections.Generic Imports System.Reflection Imports DotNetNuke.Security.PortalSecurity Partial Class DesktopModules_SuperSimple_SuperSimple Inherits Entities.Modules.PortalModuleBase End class so you see sir, I took out almost everything. then i entered code in the .aspx page: <script> code that logs in automatically a user that entered a main portal, and then clicked in my dotnetnuke portal. </script> It all works well. dotnetnuke recognizes the person. but when I try to logout, the error shows up. here is the generic code given to me. next reply Last edited by nofriends : April 17th, 2007 at 05:05 AM. Reason: added [code][/code] tags |
|
#21
|
|||
|
|||
|
Code:
<script runat="server">
Protected Sub Page_Load(ByVal O As Object, ByVal E As EventArgs)
If Not (Page.IsPostBack) Then
Dim UserName As String = Request.QueryString("empno")
Response.Write("pasok 1")
Dim intUser As Integer = Me.UserId
If (intUser > 0) Then
Else
Dim objUser As UserInfo = UserController.GetUserByName(Me.PortalId, UserName)
If Not (objUser Is Nothing) And objUser.Membership.Approved And Not (objUser.Membership.LockedOut = True) Then
UserAuthorized(objUser)
End If
End If
End If
End Sub
Private Sub UserAuthorized(ByVal objectUser As UserInfo)
Dim strMessage As String = String.Empty
Dim updatePassword As Boolean = False
Dim updateProfile As Boolean = False
Dim UserId As String = objectUser.UserID
If Not (objectUser.Profile Is Nothing) And Not (objectUser.Profile.PreferredLocale Is Nothing) Then
Localization.SetLanguage(objectUser.Profile.Prefer redLocale)
Else
Localization.SetLanguage(PortalSettings.DefaultLan guage)
End If
UserController.UserLogin(PortalId, objectUser, PortalSettings.PortalName, <ip address>, False)
Try
Response.Redirect("Default.aspx")
Catch ex As Exception
'AddModuleMessage(ex.ToString(), DotNetNuke.UI.Skins.Controls.ModuleMessage.ModuleM essageType.RedError, True)
Response.Write(ex.StackTrace)
End Try
End Sub
</script>
-----> I suspect, I dont have a logout mechanism in this module. can you help me? or could it be a different problem that's why the error shows up? thanks sir for the support. Last edited by nofriends : April 17th, 2007 at 05:05 AM. Reason: added [code][/code] tags |
|
#22
|
||||
|
||||
|
you do have code in there, so I need full error message that contains
among the rest line number. that line number tells the programmer what code cause problems, then the programmer can fix it. |
|
#23
|
|||
|
|||
|
Quote:
ok sir. but my visual studio cant build the website with debugging, it causes an error so what I do is just alt+f5 and it runs. so I cant really see the error or the line number where there is an error. only that error I gave you, the one that shows up in the site.... |
|
#24
|
|||
|
|||
|
Quote:
I tried to catch the exception nullreferenceexception: System.NullReferenceException: Object reference not set to an instance of an object. it is found in my page load, more likely to be in because it always said that I have to catch the exception of the italicized part: If Not (objUser Is Nothing) And objUser.Membership.Approved And Not (objUser.Membership.LockedOut = True) Then UserAuthorized(objUser) End If |
|
#25
|
||||
|
||||
|
And is not like the "&&" operator - the phrase objUser.Membership.Approved
will be parsed even when the first phrase is True. that's one of the reasons I prefer C language over Basic. the only way that I'm aware of in VB is like this: Code:
If Not (objUser Is Nothing) Then
If objUser.Membership.Approved And Not (objUser.Membership.LockedOut = True) Then
UserAuthorized(objUser)
End If
End If
FYI in C# it can be written in much less lines: Code:
if (objUser != null && objUser.Membership.Approved && !objUser.Membership.LockedOut ) UserAuthorized(objUser); see why many programmers prefer this language? ![]() |
|
#26
|
|||
|
|||
|
i don't get error anymore because I just catched the error and It seems that the user logs out just fine =P I will do what you suggested since I'm not doing anything else sir thanks!
by the way, I have a problem with using sessions since I'm very new in asp.net sir... could you please help me in the thread I created? How to use Sessions in asp.net I am targeting to have the website be accessible to all users in the intranet, where in they can all log in at the same time. because, i've seen, that if my previous user is logged and another would log in, that one logs in as the previous user. but when the previous user is logged out, the other can log in perfect.(this is using the automatic log in code above) about the C#, they say there are really tradeoffs. like in C#, it is not forgiving. you have to type in the correct variable or method or class with proper capitalization. it also uses braces that are not that friendly and C# is not that readable too. that's what they say. and in vb, you could design the forms and it generates the codes for you. so people here encouraged me to use it. =P though I program in java and before in college I used C. =P |
|
#27
|
|||||
|
|||||
|
Quote:
sounds like basic logic problem, we need to debug this further in other thread. Quote:
that's right, but it's very readable to those familiar with the language. same for the need to use proper case - you get used to it in some point. ![]() Quote:
same in C# - the designer does not care what language is being used. going to look in your thread later. ![]() |