|
I have a web application which is similar to group management.So every user will belong to one group.When user logs in I need to refer his group related details like group and and also his user related details such as userid,user name and assigned roles for him.Instead of getting these global details in every form,cant I store them in one place (global.asax) and refer where ever i required.If yes please provide the information and problems with it.
Thanks in advance,
Srinivas Mateti
|
|
|
|
|
if you want to store the information related to the user then you can do at the same place where User gets login. Just fetch the information from the DB for that user and then store it in a Session.
To store it in a single variable, you can create a simple class. just place the variables that would hold the info required by you. now it's very easy. just create the object of this class, assign values to the variables and then place this object in the session. Now access the session variable at any page .
modified on Thursday, September 24, 2009 9:28 AM
|
|
|
|
|
when user gets login successfully and if you are using FormAuthentication then Application_AuthenticateRequest will be fired but it will be in global.asax not global.ajax. i suppose there was a typo mistake(ajax).
|
|
|
|
|
sris 426 wrote: What type of data i can keep in global.ajax file
What kind of file Global.ajax is ? I guess you are asking for Global.asax . if yes, read sashidhar reply.
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
Hi!
How can I populate a DropDownList by what I select from another?
I have two DropDownLists named Industry and SubIndustry. The SubIndustry DropDownList should display information by what I have selected in Industry.
I have created a Populate_Industry and Populate_SubIndustry methods and I call the SubIndustry_Method by way of the Industry SelectedIndex_Changed event. I have set AutoPostBack="true" on the Industry DropDownList but the Populate_SubIndustry method won't fire.
I have stepped through my code and everything executes perfect but the information does not appear in the DropDownList. I double checked my databind code so I do not think its me not binding to the control.
Please can someone assist? If you want to see the code please reply and I will gladly post it for you.
Thank you!
Illegal Operation
|
|
|
|
|
Yes, post the code, it's the only way to be sure.
- S
50 cups of coffee and you know it's on!
Code, follow, or get out of the way.
|
|
|
|
|
here is the code:
Variables to check DropDownList State and to get the IndustryId for SubIndustry:
bool LoadSubIndustries = true;
public int IndustryId { get; set; }
Page_Load:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Populate_Industry();
}
LoadSubIndustries = false;
}
The Populate Methods:
private void Populate_SubIndustry()
{
DataSet dsSubIndustries = lookupManager.GetSubIndsutryByIndustryId(IndustryId);
ddlSubIndustry.DataSource = dsSubIndustries.Tables["Lookup_SubIndustry"].DefaultView;
ddlSubIndustry.DataValueField = "Id";
ddlSubIndustry.DataTextField = "SubIndustry";
ddlSubIndustry.DataBind();
}
private void Populate_Industry()
{
DataSet dsIndustries = lookupManager.GetIndustries();
ddlIndustry.DataSource = dsIndustries.Tables["Lookup_Industry"].DefaultView;
ddlIndustry.DataValueField = "Id";
ddlIndustry.DataTextField = "Industry";
ddlIndustry.DataBind();
}
SelectedIndex_Changed method:
protected void ddlIndustry_SelectedIndexChanged(object sender, EventArgs e)
{
if (LoadSubIndustries == false)
{
IndustryId = (int.Parse(ddlIndustry.SelectedValue.ToString()));
Populate_SubIndustry();
}
}
Illegal Operation
|
|
|
|
|
Steve,
Please ignore. I have found the problem. I have not added the table adapter to my GetSubIndustryByIndustryId method.
Boy do I feel like the idiot!!
Thanks for the quick response!!
Cheers
Illegal Operation
|
|
|
|
|
Ah, happy to be of service.
- S
50 cups of coffee and you know it's on!
Code, follow, or get out of the way.
|
|
|
|
|
Have you put a break point on the bolded line:
protected void ddlIndustry_SelectedIndexChanged(object sender, EventArgs e)
{
if (LoadSubIndustries == false)
{
IndustryId = (int.Parse(ddlIndustry.SelectedValue.ToString()));
Populate_SubIndustry();
}
}
to make sure LoadSubIndustries is false? Is it even getting into this event handler? If it's not getting to the event handler, that would indicate the event isn't wired up correctly.
- S
50 cups of coffee and you know it's on!
Code, follow, or get out of the way.
|
|
|
|
|
Dear All,
I using ASP.NET with AD. I can connect with my username and password, Can I get all username in AD?
Socheat
|
|
|
|
|
You want to authenticate user from Active Directory ? Or want to list of all user name from AD ?
Read this article, This will help you to find out all the answer.
Howto: (Almost) Everything In Active Directory via C#[^]
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
Yes, I want toget all user name from AD
Socheat
|
|
|
|
|
|
I need some help on how to validate the userName and password against a database for a login system in Visual C#? Help!!!!
|
|
|
|
|
First, read this[^]
Second, read this[^]
only two letters away from being an asset
|
|
|
|
|
Mark Nischalke wrote: First, read this[^]
I believe you meant this[^].
|
|
|
|
|
I hate it when they don't answer.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Yep, got the wrong one
only two letters away from being an asset
|
|
|
|
|
There is no such thing as APS.NET. I get the impression you have no idea what you're doing. That doesn't make for a secure login system. Perhaps you should pay someone to do it for you. Be careful if you decide to list this job on places like rentacoder, because some people advertise on places like that, take jobs they can't do, and post here asking us to do it for them. We tend not to do work for people who are being paid and have no clue.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
hello
i find a great article about data access, it is to sql
i change the data access to work with sybase
i change the sql object by sybase object
Protected Overloads Sub ExecuteNonQuery(ByRef cmd As AseCommand, ByRef procName As String, ByVal ParamArray
procParams() As IDataParameter)
'Method variablesoutDim cmd As SqlCommand
Dim cnx As AseConnection = Nothing
cmd = Nothing
'Avoids "Use of unassigned variable" compiler error
Try
'Setup command object
cmd = New AseCommand(procName)
cmd.CommandType = CommandType.StoredProcedure
Dim index As Integer = 0
Do While (index < procParams.Length)
cmd.Parameters.Add(procParams(index))
index = (index + 1)
Loop
'Determine the transaction owner and process accordingly
If _esIniciante Then
cnx = New AseConnection(GetConnectionString)
cmd.Connection = cnx
cnx.Open()
Else
cmd.Connection = _txn.Connection
cmd.Transaction = _txn
End If
'Execute the command
cmd.ExecuteNonQuery()
Catch ex As Exception
Throw
Finally
If _esIniciante Then
cnx.Dispose()
End If
If (Not (cmd) Is Nothing) Then
cmd.Dispose()
End If
End Try
End Sub
when call the function ExecuteNonQuery
Public Function Cliente_obtenerPorCedula(ByRef clienteID As Integer, ByVal cedula As String) As DataSet
Dim cmd As AseCommand
ExecuteNonQuery(cmd, "crm_co_clientecedula", _
CreateParameter("@i_cliente_id", AseDbType.Integer, clienteID, ParameterDirection.Output), _
CreateParameter("@i_cedula", AseDbType.NVarChar, cedula))
clienteID = CType(cmd.Parameters("@i_cliente_id").Value, Integer)
cmd.Dispose()
End Function
everything runs fine until invoke the code cmd.Parameters("@i_cliente_id").Value
ocurr the exception --> Run-time exception thrown : System.ObjectDisposedException - Cannot access a disposed object.
Object name: 'AseCommand: '.
the dispose cause exception
Catch ex As Exception
Throw
Finally
If _esIniciante Then
cnx.Dispose()
End If
If (Not (cmd) Is Nothing) Then
cmd.Dispose()
End If
End Try
the cmd.dispose -->System.ObjectDisposedException - Cannot access a disposed object.
the cnx.dispose -->Parameters {"Cannot access a disposed object.Object name: 'AseCommand: '.
while i comment this line, the code work
'If _esIniciante Then
' cnx.Dispose()
'End If
'If (Not (cmd) Is Nothing) Then
' cmd.Dispose()
'End If
where can be the problem ?
the original code is c# and sql that's work fine
me email is raquidd@yahoo.com
regards
sorry for me english
|
|
|
|
|
when you call
ExecuteNonQuery(cmd, "crm_co_clientecedula", _
CreateParameter("@i_cliente_id", AseDbType.Integer, clienteID, ParameterDirection.Output), _
CreateParameter("@i_cedula", AseDbType.NVarChar, cedula))
It will dispose cmd as it is ByRef. So cmd.Parameters will fail. Properties of Disposed object is inaccessible.
|
|
|
|
|
Abhishek Sur wrote: It will dispose cmd as it is ByRef.
This is not because it is passed as ByRef . It will get disposed even you pass as ByVal .
|
|
|
|
|
I dont know if you tried this in VB or not.
Initially this was my conception as well... I thought everything that is not derived from ValueTypes are called ByRef.
But it isnt actually.
If you call using ByVal , you can change any properties inside the object and it will reflect the caller, but it will not allow setting the actual object to Nothing or Dispose it. Only If you call using ByRef it allows this.
You may try out this :
Dim b As New SqlClient.SqlCommand()
x(b)
b.CommandText = "" ' this will allow Because of ByVal but will assign ' value ddd to CommandText
Public Sub x(ByVal rr As SqlClient.SqlCommand)
rr.CommandText = "dddd"
rr.Dispose()
rr = nothing
End Sub
You can try this.
Even this does happen in C#.
private void button1_Click(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand();
this.x(ref cmd);
cmd.CommandText = "";
}
private void x(ref SqlCommand com)
{
com = null;
}
Just removing the ref keyword will allow this ...
|
|
|
|
|
Abhishek Sur wrote: I thought everything that is not derived from ValueTypes are called ByRef.
But it isnt actually.
In .NET, parameters are passed by value by default. A reference type is passed as value but the value will be a reference. This is the reason why setting null is reflecting at the caller side. But you still can call Dispose() as it is just a method in the type.
|
|
|
|