Fredrik Normén's Blog - NSQUARED²
Any fool can write code that a computer can understand. Good programmers write code that humans can understand.

Microsoft Most Valuable Professional
     .Net Framework - ASP.Net - Architecture - Development
NOTE: This list of posts will only list the 15 latest posts, to see the rest, select from the Archives located in the menu to the left. The RSS will only list the 10 lastest posts.
Bind resources in VS.Net 2005

Category:  ASP.Net 2.0

Visual Studio .Net 2005 will now automaically bind a resource string to a controls property

<asp:Button ID="Button1" Runat="server" Text='<%$ Resources:ClassName, ResourceKey, "DefaultValue" %>' />

ClassName:

The name of the class that contains the resource.

 

ResourceKey:

The key specifying the resource.

 

DefaultValue:

The default value for the expression if the resource is not found.

 

You could also bind values added to the AppSettings in the configuration file:

 

<asp:TextBox ID="TextBox1" Runat="server" Text="<%$ AppSettings:test %>"></asp:TextBox>

 

Or a value from the connectionStrings:

 

<%$ ConnectionStrings:AccessFileName %>

 

For you how are interested in the progress of the Permission Manager for Visual Studio .Net 2005 I'm working on, here are some of new API‘s for setting permissions for users and roles. 

 

public static void SetPermissionForUser(string sourceId, string userName, string permission, PermissionType permissionType) 

 

public static void SetPermissionForUser(string sourceId, MembershipUser userName, string permission, PermissionType permissionType) 

 

public static void SetPermissionsForUser(string sourceId, MembershipUser userName, Permission[] permissions) 

 

public static void SetPermissionsForUser(string sourceId, string userName, Permission[] permissions) 

 

public static void SetPermissionsForUsers(string sourceId, MembershipUser[] userNames, Permission[] permissions)

 

public static void SetPermissionsForUsers(string sourceId, string[] userNames, Permission[] permissions) 

 

public static void SetPermissionForRole(string sourceId, string roleName, string permission, PermissionType permissionType) 

 

public static void SetPermissionsForRole(string sourceId, string roleName, Permission[] permissions) 

 

public static void SetPermissionsForRoles(string sourceId, string[] roleNames, Permission[] permissions) 

 

public enum PermissionType

{

   Allow,

   Deny,

   Unspecified

}

 

I got a suggestion from sn1p3t (I hope he will give me his fullname ;) ) to make it possible to group sources by adding an extra argument.

 

Permissions.SetPermissionForUser("Fourm", 10, "Fredrik" , "Read" );

 

I’m thinking of implementing this, but probably I will use some sort of Source class to avoid too many arguments to the methods.

 

 

Posted: Tuesday, March 23, 2004 - 20:24 GMT+1    Print     E-mail    Comments (2)
   fredrik.nsquared2.com - 2007