Script to Make TextBox to Enter Only NUMBER

Labels:

<script language=javascript>
function NumberOnly()
{
var keyCode = event.keyCode;

if(keyCode > 47 && keyCode < 58)
{
return true;
}
else
{
return false;
}
}
</script>

<asp:TextBox ID="txt" runat="server" onkeypress="return NumberOnly()"></asp:TextBox>

Place the Script in the keyPress Event of the textbox to see the result.

To write a Script in server side in Asp.net

Labels: ,

Syntax :

ScriptManager.RegisterStartupScript(Control control,type type,string Key,string Script,bool addScriptTags)

Example:

string s = "alert('Hello')";

ScriptManager.RegisterStartupScript(this, this.GetType(), "Hello", s, true);

If you give the script tag in the string s then give addScriptTags to false.

ScriptManager is a class inside System.Web.UI

As a result a alert box with 'hello' pops up, where you place this line.

Authorization

Labels:

Authorization is to determine whether an identity should be granted the requested type of access to a given resource.

users: Assign a list of users to be granted or denied access

Roles: Assign a list of roles to be granted or denied access

<authorization>
<allow users="Don , Jim" roles="Admins" /> //Allow only two user Don,Jim

<deny users="*" /> //Restrict all other user

</authorization>

//Allow All the user to access

<authorization>
<allow users="*" />
</authorization>

* Refers to all identities
? Refers to the anonymous identity