Friday, December 23, 2011

overflow: scroll / hidden



<html>
<head>
<style type="text/css">
div.scroll
{
background-color:#00FFFF;
width:150px;
height:100px;
overflow:scroll;
}

div.hidden
{
background-color:#00FF00;
width:150px;
height:100px;
overflow:hidden;
}
</style>
</head>

<body>
<p>The overflow property specifies what to do if the content of an element exceeds the size of the element's box.</p>

<p>overflow:scroll</p>
<div class="scroll">You can use the overflow property when you want to have better control of the layout. The default value is visible.</div>

<p>overflow:hidden</p>
<div class="hidden">You can use the overflow property when you want to have better control of the layout. The default value is visible.</div>
</body>
</html>

Tuesday, December 20, 2011

text-overflow:ellipsis/clip with white-space:nowrap;


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style type="text/css">
div.test
{
white-space:nowrap;
width:12em;
overflow:hidden;
border:1px solid #000000;
}
</style>
</head>
<body>

<p>The following two divs contains a long text that will not fit in the box. As
you can see, the text is clipped.</p>

<p>This div uses "text-overflow:ellipsis":</p>
<div class="test" style="text-overflow:ellipsis;">This is some long text that will not fit in the box</div>

<p>This div uses "text-overflow:clip":</p>
<div class="test" style="text-overflow:clip;">This is some long text that will not fit in the box</div>

</body>
</html>

Wednesday, January 19, 2011

ASP.NET Security

Security
Introduction
Authentication
Authorization – which particular directories, resources that particular user allows to access

Authentication
1.) Users Forms Authentication
2.) Windows Authentication

Users Forms Authentication
system.web&gt;
..
authentication mode="Forms"&gt;
forms name="MyAuthCookie" loginUrl="~/Login.aspx" timeout="30"&gt;
/forms&gt;
/authentication&gt;


authorization&gt;
deny users="?"/&gt; //deny unauthenticated users
/authorization&gt;

/system.web&gt;

name – name of the cookie that send back to the client
loginUrl – when user attempt to visit any page of the web site asp.net automatically redirect to the web page u specify here


system.web&gt;
..
authentication mode="Forms"&gt;
forms name="MyAuthCookie" loginUrl="~/Login.aspx" timeout="30"&gt;
credentials passwordFormat=”Clear” &gt;
user name=”anuruddha” password=”aaa”&gt;
user name=”mahanama” password=”bbb”&gt;
/credentials&gt;
/forms&gt;
/authentication&gt;

/system.web&gt;

protected void LoginButton_Click(object sender, EventArgs e)
{
string username = NameTextBox.Text;
string password = PasswordTextBox.Text;

if (FormsAuthentication.Authenticate(username, password))
//if (Membership.ValidateUser(username, password))
{
FormsAuthentication.RedirectFromLoginPage(username, false); //if need to keep a cookie abt user details even though user log out , set this to true
}
else
{
MessageLabel.Text = "Invalid username or password.";
}
}

credentials passwordFormat=”Clear” &gt;
user name=”anuruddha” password=”aaa”&gt;
user name=”mahanama” password=”bbb”&gt;
/credentials&gt;
Rather than this there is better way to do this using membership store.


Membership store
There is API in asp.net which talks to DB n get the membership info. That means u dnt have to put credentials here.

Microsoft Visual Studio 2008  Visual Studio Tools  Visual Studio 2008 command prompt
And run following batch file
aspnet_regsql -S -E –A all
-S = idenfy where ur sql server instance is located
= as my sqk server instance is in in my local machine
-E = how u going to authenticated run the command , (-E I am going to use windows authentication)
-A = which particular table u want to create (here I am creating all)
This create new DB in my sql server instance. It include table abt membership, personalization. Now u van use membership mechanism to store my user info. But how we get the user info into membership data store. U use web site administrator tool for that.

Website  ASP.NET Configuration N u will see security tab.
When u use the membership
if (Membership.ValidateUser(username, password))
{
FormsAuthentication.RedirectFromLoginPage(username, false); //if need to keep a cookie abt user details even though user log out , set this to true
}
else
{
MessageLabel.Text = "Invalid username or password.";
}
}

Now use the login control that come with asp.net and go to events and generate the event authenticate which equivalent to the pressing the logging button
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
{
if (Membership.ValidateUser(Login1.UserName, Login1.Password))
FormsAuthentication.RedirectFromLoginPage(Login1.UserName, false);
}





This means that asp.net is not authenticate u, u are authenticated by IIS

Internet Information Service
Create new virtual dir. Then configure the property, in particular in the directory security -&gt; anonymous access and authentication control. Tick the Integrated windows authentication(windows logging info is go to server)


Authorization

authorization&gt;
deny users="?" /&gt; //anonymous user not allowed
allow users="ANDYO\Andy Olsen "/&gt; // grant permission this user (machinename/username)
deny users="*"/&gt; //deny for all other users
/authorization&gt;
Authorization here is apply for this particular folder. U can specify web.config file in sub folders if u need to have different security levels in each sub folders.