Joseph Michael Pesch
VP Programming

HTML Object Visibility/Display

by 21. January 2009 13:58

Two basic options for HTML style based visibilty/display are the style tags shown below:  Setting "visibility: hidden;" hides the object; but, retains the same physical space/layout; while setting "display: none;" allows the object to effectively go away completely, resulting in the physical space being available for other objects.  Additionally, there are differences in IE vs. Firefox related to toggling objects display property.  The best method compatible with both seems to be setting "display: none;" to hide.  To make it visible again remove the display tag entirely or set it to a blank value in javascript (i.e. obj.style.display = '';), this is because using block, inline and inherit all cause format issues in Firefox (specifically pertaining to HTML tables, which will have each cell retaining it's own width rather than sharing a single width for all cells in a given column).  Here is a simple example function to toggle an objects visibility:

<script id="ToggleDisplayScript" language="javascript" type="text/javascript">
  function ToggleDisplay(obj) {
    obj.style.display = obj.style.display == 'none' ? '' : 'none';
  }
</script>

Tags: ,

[None]

Declarative Security Checks for User Name and/or Role Permission

by 6. January 2009 18:46

[PrincipalPermissionAttribute(SecurityAction.Demand, Name =  "UserName", Role = "UserRole")]
publicstaticvoid SecurityTestEntryPoint(bool flag)
{
  if (flag)
  {
    // This is more secure code...

    SecurityTest(flag, "");
  }
  else

  {
    // This is less secure code...

    SecurityTest(flag);
  }
}
[PrincipalPermissionAttribute(SecurityAction.Demand, Role = "ManagerRole")]
publicstaticvoid SecurityTest(bool flag, string MoreSecure)
{
  // This is more secure code...

}
[PrincipalPermissionAttribute(SecurityAction.Demand, Role = "ManagerRole")]
[PrincipalPermissionAttribute(SecurityAction.Demand, Role = "UserRole")]
publicstaticvoid SecurityTest(bool flag)
{
  // This is less secure code...

}

NOTE: You can stack multiple attributes for an OR condition, however, you cannot create an AND condition. As in the example above the less secure method will let both "ManagerRole" users and "UserRole" users access itself.

Topic Links:

http://msdn.microsoft.com/en-us/library/dswfd229(VS.71).aspx

http://bytes.com/groups/net-c/267605-cas-multiple-permissions

 

Tags: ,

C# | Security

Getting Fully Qualified URL in ASP.Net Code

by 5. January 2009 22:33

Request.Url.AbsoluteUri.Replace(Request.Url.PathAndQuery, ResolveUrl("~/SubFolderIfAny/TheFile.aspx"));

Tags: ,

ASP.Net