473,569 Members | 2,791 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with accessing function in page load Method

37 New Member
Hi All,

I am having a problem with accesing function in the page. i have a page say user.aspx in the page load method
i am calling function to validate the user.


it works fine when single user access the page but when another user try to access the page then it crash the
first users processing and empty the session variable.

means when i am calling function in the page load of user.aspx then it is giving me problem.
and if i write user validation code direct in page load method then it works fine.

problem occurs only when i write user validation code in function and try to call that function in page load of
user.aspx

Expand|Select|Wrap|Line Numbers
  1.  Private Sub Page_Load
  2.  
  3.  
  4.  
  5.       IF validateUser() THEN      
  6.  
  7.               Response.write ("Welcome" & sUserID )
  8.     Else
  9.             Response.Redirect("UserNotFound.aspx?userid=" & sUserID & "&Form=DataXS")
  10.        End If
  11.  
  12.  
  13.  End sub
  14.  
  15.  
  16.  Public Function validateUser() as boolean
  17.  
  18.     Dim dbOleDbDataReader As OleDbDataReader
  19.     dim bflag as boolen
  20.  
  21.                         sSQL = "Select NAME From kuaf where lower(NAME)='" & LCase(sUserID) & "' 
  22.  
  23.                         Dim sConnectionString As String = xsData.getDatabaseConnection(sLogFile)
  24.                         Using dbConnection As New OleDbConnection(sConnectionString)
  25.                             Dim dbcommand As New OleDbCommand(sSQL, dbConnection)
  26.                             dbcommand.CommandType = CommandType.Text
  27.                             dbcommand.Connection.Open()
  28.                             dbOleDbDataReader = dbcommand.ExecuteReader()
  29.  
  30.                             If Not dbOleDbDataReader Is Nothing Then
  31.                                 If dbOleDbDataReader.Read() Then
  32.                     bflag = True
  33.                                 Else
  34.                                     Response.Redirect("UserNotFound.aspx?userid=" & sUserID & "&Form=DataXS")
  35.                                 End If
  36.                             End If
  37.  
  38.                             dbOleDbDataReader.Close()
  39.                             dbOleDbDataReader = Nothing
  40.                             dbcommand.Dispose()
  41.                             dbcommand = Nothing
  42.                             dbConnection.Close()
  43.                         End Using
  44.  
  45.     Return bflag 
  46.  
  47.  End Function 
can u tell me why it is happening..

Thanks

-Joseph
Sep 8 '08 #1
1 1455
kenobewan
4,871 Recognized Expert Specialist
If boolean value true or false. Return result first and then test whether the result is t or f. However I notice you have a typo in declaring bflag.
Sep 8 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
6919
by: WFB | last post by:
Hi, I have a base class from which all of my pages derive (ABCBasePage). For example, ABCCustomerSelect Inherits ABCPasePage. I would now like to have ABCPocketSelect which should inherit from ABCCustomerSelect. My problem is that when ABCPocketSelect is loaded the Page_Load event in ABCBasePage is called, followed by the load event for...
5
7515
by: Asa Monsey | last post by:
I am having a problem that the page load event fires twice in reponse to an autopostback. The first time, the IsPostBack property is true, and the second time it it false. This is causing many uneeded database calls, since many of them do not need to be fired on a PostBack. I have already set the AutoEventWireup=false in the ASPX @Page...
7
23326
by: UJ | last post by:
I've got a page with a user control on it. While the page is loading, it needs to check certain conditions of the user object to enable/disable things on the screen. Currently in the page_load of the user control I do things like read from the database on the first load, set some internal variables, ... If I need those things to be...
15
10058
by: H00ner | last post by:
Hello All Hope you can help Been pulling my hair out about a popup problem in ASP.NET. One of the forms i wrote requires the user to select a product from a list in a popup web form. the popup has a DataGrid on it and the page.load function DataBinds as you'd expect. I have Code-Behind in C# to emit a call to a JavaScript function...
3
4244
by: Jason | last post by:
I have an ASP.NET application in which I would like to call my button click event (imgSubmitSearch_Click) on the page load if certain criteria are met. Is this possible? What is the correct syntax to be able to programmatically have my imgSubmitSearch button clicked? I tried the obvious, Call imgSubmitSearch, but intellisense doesn't like...
0
314
by: R.A.M. | last post by:
Hi, Could you help me please with a problem of infinite page load? I have an ASP.NET page (texts in Polish; meaning not important): <%@ Page Language="C#" AutoEventWireup="true" CodeFile="FormularzeWWW.aspx.cs" Inherits="FormularzeWWWPage" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
0
1598
by: manywolf | last post by:
I have an aspx page that fires the page load event twice for every load. I tried every fix that was suggested in all the posts on this and other forums. None changed the behavior. After one post that suggested they had an img tag with src="", I decided to look for instances of "src" and one by one start removing that code to see if it changed...
1
1387
by: deepakbarolia | last post by:
hi, i am working on dotnet. I have a pop up window opening from the basepage. The pop up window contains only datagrids and a button. On page load i need to point to the top of the page. The problem is on page load when there are no editable controls in the webpage, then by default the dotnet sets the focus to the button. so even if i use...
1
3622
by: ahmh | last post by:
The javascript function is called getsportart2 in the codebehind page_load I have the following Page.RegisterStartupScript("MyScript3","<script type='text/javascript' src='http://www.halaeducation.com/media/modules/sports/getsportart2.js'></script>"); I would like to activate this function as soon as the page load. I do not have a...
0
7693
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7605
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7665
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2105
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
933
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.