|
User.Identity.Name will be null if no user is logged in (depends on the Authentication mode).
|
|
|
|
|
Good Afternoon,
I am new to ASP.NET. I am used to C# windows delveloper. In all my previous projects we had a seperate solution to handle the Data Access Layer. This layer had all the logic for logging in and communicating with the database.
How do I move the Login (currently I am using Memberships that is setup in my config file) to the DAL layer? Should it be in the DAL layer?
Thanks for all your help.
Chris
|
|
|
|
|
Membership having it own internal implementation. If you want to move membership, you can use DAL for all database related code. Even inbetween DAL and UI, you can put the Business Layer also (BLL).
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
You're trying to keep seperation of concerns, as you should. The problem is, Asp.Net web applications are very much dependant on app and web.configs, which don't run in class libraries.
I don't use .Net Memberships. I created my own role-based security model (did this before I started using .Net) and created data providers to go with it. Also, I use a ConnectionProviderFactory (returns an IDbConnection) class to maintain connection strings so my Dals can be completely independant from the applications using them.
There are some useful features provided in .Net but if you require more abstraction and extensibility you sometimes need to break-out a little.
|
|
|
|
|
Hi
Thanks for your input.
Is it really worth going through all the trouble to implement a DAL layer? What is the cons of creating your own role-based security model? And how much work are we talking about. I am fairly new to ASP.NET. Coded alot in VB.NET and C#. When you did this how many stops did you find along the way?
Thanks
Christiaan
|
|
|
|
|
I have searched the web for articles on how to create a custom membership and provider to move this to the DAL layer and have only find articles that do something simular for legacy programs.
Is this not the right patht to go along anymmore?
|
|
|
|
|
DALs are still very popular and play a big role in n-Tier design. It's all about seperation of concerns/code maintenance: Your GUI code and your business logic code don't need to understand the database; they don't need to understand SQL, so abstract this kind of code.
There are some really useful, really cool things in .Net but in my opinion, a few of them ignore good practice - putting connectionStrings in the application is one of them. However, it does depend on how scalable your application needs to be. If your app. consists of a couple of forms for a HR dept to add new staff, and isn't likely to grow much then I'd say...yeah...go with .Net Membership and don't concern yourself too much about design patterns, stick your db properties in the app.config/web.config.
It's all about context really. What kind of application are you working on? Is this a team project or is it an app you're doing on your own?
I'll see if I can find some detailed articles for you.
|
|
|
|
|
Hi
I agree that placing connection strings in the UI's config in not a very good practice to persue. My project currently is small and it is only me that develops it. But over time it can grew to a couple of 1000 users and we will have to get in other developers.
The whole membership works cool with roles and everything. I will appreciate the articles. Thanks
|
|
|
|
|
I have to validate SSN which will be entered in 3 different textboxes (txtSSN1, txtSSN2, txtSSN3).
1. If SSN1 is entered and other TWO textboxes are left blank, then CustomValidater should raise an error.
2. If all 3 textboxes are blank, then is a valid scenario. return true and save.
3. If all 3 textboxes are entered with values, return true.
As I have these controls in a Repeater, I cann't able to find the controls from clientside. Need help
Regards,
Ravi K. Kalyan
|
|
|
|
|
You can validate on OnItemDataBound event of repeater.
Please don't forget to mark 'Good Answer', if you find it really a good one!
Kashif
|
|
|
|
|
What is the problem with that. Repeater actually places the same html that you define in ItemTemplate and AlternateItemTemplate .
You can easily use OnItemDataBound event to find the controls. Inside it write like this:
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternateItem)
{
TextBox tb = e.Item.FindControl("yourserversideiD");
tb.Attributes.Add("onblur", yourjavascript);
}
Like this way you can easily find any serverside control inside Repeater and apply your javascript.
so try this out..
|
|
|
|
|
Guys, Thanks for the reply.
All I need is a client side validation.
Server side is just a matter of 20min for me... I'm looking for a client side validation.
Thanks
Regards,
Ravi K. Kalyan
|
|
|
|
|
Hey Ravi... Believe me.. I was really talking about client side validation in the code above.
onblur is a client side event, I think.
Just place your javascript there. Call the validation javascript from there.
if you pass like this :
txt.Attributes.Add("onblur", "javascript:func(this)")
you will get the txtbox on the function.
Also you might use txt.ClientId to pass the id.
|
|
|
|
|
My requirement is to validate the SSN in Save_Click event.
NOT in "Onblur" event.
I also have "Add Child" button using which I'm adding new Repeater.. So I can add N number of children before clicking on save button. And each repeater is having SSN1, SSN2 and SSN3 textboxes that I need to validate.
Thanks for the replies.
Ravi
Regards,
Ravi K. Kalyan
|
|
|
|
|
Ok.. so for each SSN1, SSN2 and SSN3 you will be having one button..
So do like this :
Button btn = e.Item.FindControl("yourbuttonid");
TextBox SSN1 = e.Item.FindControl("SSN1ID");
TextBox SSN2 = e.Item.FindControl("SSN2ID");
TextBox SSN3 = e.Item.FindControl("SSN3ID");
string script = "javascript:validate('" + SSN1.ClientId + "','" + SSN2.ClientId + "','" + SSN3.ClientId + "');";
btn.Attributes.Add("onclick", script);
Now in the page designer, place a script tag and add a function validate :
function validate(ssn1id, ssn2id, ssn3id){
var ssn1 = document.getElementById(ssn1id);
var ssn2 = document.getElementById(ssn2id);
var ssn3 = document.getElementById(ssn3id);
}
I home this is what you wanted.
|
|
|
|
|
Hi,
I want to create a Grid View in C# dynamically and add columns and data into it ... I tried it in all sources what i know nut i failed can any body help me out.. Please...
the way i tried is
GridView dg=new GridView();
dg.columns="admin";
.....
.....
Regards,
Pardhu..
|
|
|
|
|
where do you get the data?
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
|
Hi,
I have gridview and I used 2 button in that grid view. Now I want first column value from selected rows button from the gridview.
I am using Itemtemplate in which buttons are there in that ItemTemplate
e.g. If I click on the 3rd rows button then I want 1st column value from 3rd row.
Thanks
Sjs
|
|
|
|
|
Is it a commandfield button or just a standard button?
|
|
|
|
|
use the following
Gridview.rows[index].cell[0].text
This way u will get the data..
|
|
|
|
|
Hi,
If you are using <asp:button> in template field of column then you can get the value of selected row's first column in that button's click event.
e.g
protected void Button1_Click(object sender, EventArgs e)
{
Button btn = sender as Button;
GridViewRow row = btn.NamingContainer as GridViewRow;
//Get the First Column's value
string value = row.Cells[0].Text;
}
|
|
|
|
|
Hi,
I have a page navigation problem for the previous page when i am trying to navigate user to the previous page using the following javascript stmt
window.location.href='welcome.aspx';
the above page resides in the same directory as the current page.
This problem is coming when i am trying to browser the site from other system.From local system it was working fine.
pl help me if anyone has come across with the same problem?
Thanks...
|
|
|
|
|
In mozilla,while seeing print preview not showing all the records.....
send me some solution...
thanks
modified on Thursday, November 26, 2009 6:36 AM
|
|
|
|
|
Good. So what is your question?
Please read the posting guidelines and rephrase your question.
Best wishes,
Navaneeth
|
|
|
|