Wednesday, 13 June 2012

ASP.NET & C# ---- Using RadioButton ,TextBox and Panel control


RadioButton Control:




TextBox Controls:



It is hard to find an ASP.NET application that does not use a TextBox control. It allows the user to interact with the web application you created and hence can provide Dynamic nature to the web application.The venerable HTML input and textarea elements provide alternatives, but they include fewer features and ASP.NET integration.
The basic premise of the TextBox control is accepting user input. This may be as simple as a user entering a username or typing a multiline paragraph. The control provides plenty of methods and properties to work with it via code.


 The TextBox control has the  following properties:
  • AutoPostBack: Boolean value signaling whether the AutoPostBack feature is enabled for the control. This determines if the form will automatically be posted back to the Web server when the contents of the field change.
  • BackColor: The background color of the control. This may be controlled with CSS as well.
  • BorderColor: The border color for the border (if used) displayed around the control.
  • BorderWidth: The width of the border around the control on the page.
  • CausesValidation: Boolean value signaling whether validation is performed when postback of form is executed.
  • Columns: The display width of the TextBox control.
  • CssClass: Allows you to assign a CSS class to the control.
  • Font: The various font attributes associated with the control. The preferred approach is to use CSS, but the Font class contains properties for signaling whether the text appears in bold, italic, strikeout, or underline, as well as font size, name, and more.
  • ForeColor: The color of the text displayed in the field. The preferred technique is CSS.
  • Height: Get or set the height of the control.
  • MaxLength: The maximum number of characters allowed in the field.
  • ReadOnly: Boolean value signaling whether control may be edited by user or just read only.
  • Rows: The number of rows for a TextBox using the multiple line setting.
  • SkinId: Allows you to assign a skin to the TextBox to control its appearance.
  • Text: The text contained within the field.
  • TextMode: The text mode of the control. The legal values are found in the TextBoxMode class with values of single-line, multiline, or password. The password setting masks the text entered, so the password is not displayed — it is available in the code for manipulation and storage.
  • Visible: Boolean value signaling whether the control is visible or hidden.
  • Wrap: Boolean value signaling whether text wraps within the field.

Panel Control:






creating an ASP page with the following information :

  • ·       Page should contain list of radio button controls which can be used to select a language from a list of programming languages
  • ·      The last radio button is labelled other if you select the other radio button the content of the panel control are revealed


languageSelector.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="languageSelector.aspx.cs" Inherits="Radio" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Subject</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <font color="red"><b><asp:Label id="Label2" Text="Select a Language:" Runat="server" /></b></font><br />
    <table>
    <tr><td><asp:RadioButton ID="rb1" Text="C++" GroupName="subject" runat="server"></asp:RadioButton></td></tr>
    <tr><td><asp:RadioButton ID="RadioButton1" Text="C programming" GroupName="subject" runat="server"></asp:RadioButton></td></tr>
    <tr><td><asp:RadioButton ID="RadioButton2" Text="Java" GroupName="subject" runat="server"></asp:RadioButton></td></tr>
    <tr><td><asp:RadioButton ID="RadioButton3" Text="C#" GroupName="subject" runat="server"></asp:RadioButton></td></tr>
    <tr><td><asp:RadioButton ID="RadioButton4" Text="PHP" GroupName="subject" runat="server"></asp:RadioButton></td></tr></tr>
    <tr><td><asp:RadioButton ID="RadioButton5" Text="other" GroupName="subject" runat="server"></asp:RadioButton></td></tr>
    <tr><td><asp:Panel Visible="false" ID="panel2" runat="server">
    <font color="blue"><b><asp:Label id="lblOther" Text="Other Language:" AssociatedControlID="Other" Runat="server" /></b></font><br />
    <asp:TextBox ID="other" runat="server"></asp:TextBox></asp:Panel></td></tr>
    <tr><td><asp:Button ID="submit" Text="submit" runat="server" OnClick="xyz" /></td></tr>
   
    </table>
   
    </div>
    </form>
</body>
</html>

languageSelector.aspx.cs
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Radio : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void xyz(object sender, EventArgs e)
    {
        if (RadioButton5.Checked)
        {
            panel2.Visible = true;

        }
        else
        {
            Response.Write("your form was submitted");
        }
    }
}






Tuesday, 12 June 2012

JQuery mouseover effect sample for website gallery


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Abivyakti-The fun Learning site</title>
<style type="text/css">
</style>
<link href="css/Tabs.css" rel="stylesheet" type="text/css" />
<h1 style="text-align:center;"><font size="10" face="Comic Sans MS, cursive" color="#CC0033"><blockquote><img src="Image/disney-graphics-baby-disney-961731.gif" align="middle" height="200px" width="200px" /><img src="Image/g.gif" align="middle" height="80px" width="80px" /><img src="Image/a.gif" align="middle" height="80px" width="80px" /><img src="Image/l.gif" align="middle" height="80px" width="80px" /><img src="Image/l.gif" align="middle" height="80px" width="80px" /><img src="Image/e.gif" align="middle" height="80px" width="80px" /><img src="Image/r.gif" align="middle" height="80px" width="80px" /><img src="Image/y.gif" align="middle" height="80px" width="80px" /></blockquote></font>
</h1>
<script src="script/jquery-1.7.1.min.js" type="text/javascript"></script>
<script type="text/javascript" >
$(document).ready(function(){
$('a img').animate({
opacity:.5
});
$('a img').hover(function(){
$(this).stop().animate({opacity:1},'fast');
$(id="hib").play(src="Audio/1.mp3");
},function(){
$(this).stop().animate({opacity:0.5},'slow');
$(id="hib").stop();
});
});
$(function(){
$('a.click').click(function(){
$('embed').remove();
$('body').append('<embed src="Audio/1.mp3" autostart="true" hidden="true" loop="false">');
});
$('hib').mouseover(function(){
$('embed').remove();
$('body').append('<embed src="hover.wav" autostart="true" hidden="true" loop="false">');
});
});
</script>
</head>
<body bgcolor="#CCCCCC" background="Image/bckkids.png">
<div id="navbar">
<div id="holder">
<ul>
<li><a href ="Abhivyakti_home.html" id="onlink">Home</a></li>
<li><a href="Garden.html">Garden</a></li>
<li><a href="Excercise.html">Excercise</a></li>
<li><a href="Contact.html">Contact</a></li>
<li><a href="Help.html">Help</a></li>
</ul>
<br />
<div id="Album">
<a href="#" class="click"><img src="Image/Hibiscus-1.jpg" height="250" width="250" /></a>
<a href="#" class="hover"><img src="Image/Lilac-2.jpg" height="250" width="250"/></a>
<a href="#"><img src="Image/Lotus-2.jpg" height="250" width="250" /></a>
<a href="#"><img src="Image/Orchid_1.jpg" height="250" width="250"/></a>
<a href="#"><img src="Image/Sunflower-1.jpg" height="250" width="250"/></a>
<a href="#"><img src="Image/Tulip-3.jpg" height="250" width="250" /></a>
<a href="#"><img src="Image/Peony-1.jpg" height="250" width="250" /></a>
<a href="#"><img src="Image/rose-3.jpg" height="250" width="250" /></a>
<a href="#"><img src="Image/pink_Carnation_flower_image.jpg" height="250" width="250" /></a>
<a href="#"><img src="Image/images.jpg" height="250" width="250" /></a>
<embed height="0px" width="0px" loop="infinite" src="Audio/.mp3" AUTOSTART=true />
</div>
<br>
</body>
</html>




Steps to Install Ubuntu 12.04 LTS (Precise Pangolin) from CD along side Windows7


Select and download one of the images :

  • Burn a Desktop installation CD

Burning a desktop CD allows you to try Ubuntu without changing your computer at all, and at your option to install it permanently later. The pre-requisite for this option is  at least 384MiB of RAM to install from this CD.

  • Burn a Server installation CD

Burning a server install CD allows you to install Ubuntu permanently on a computer for use as a server. But the catch is it will not install a graphical user interface.


They all offer two images available, each for a different type of computer:

  • PC (Intel x86)
  • 64-bit PC (AMD64) 


.
Steps:
  1. Download wubi.exe installer for Ubuntu 12.04 from  http://www.ubuntu.com/download/desktop/windows-installer
  2. Go to boot folder
  3. Select i386.x.ubuntu
  4. Select i386.x.ubuntu.cnf
  5. set installation drive 
  6. Set the installation size
  7. Select username 
  8. Set password
Windows Wubi installer for Ubuntu 12.04 






Sunday, 13 May 2012

ASP.NET Security

The security in ASP.NET framework is done in two steps:
  • Authentication 
  • Authorization

So in this article we will discuss about both of the above mentioned steps.


AUTHENTICATION:


  • The new feature  of ASP.NET form Authentication  which uses the membership feature uses the user credentials for this purpose.   
  • This feature of membership control supports :  SqlMembershipProvide and  ActiveDirectoryMembershipProvider
  • also ASP.NET also provides the built in support Login controls that enables you to create a login and user registration form without writing any code. 
  • Modes of authentication

  1. Window based
  2. Form based
  3. windows Password

  • Method of authentication : Authenticating the user is handled by the code written in the web.config file of your application.
  • Syntax :
For window based authentication:
<authentication mode="Forms">

For Form based authentication:

<authentication mode="Forms">
  • Protecting form authentication:This is done by securing the user credentials and authentication ticket. This can be done encrypting the cookies.
User credentials can be secured by using Strong passwords to protect against the brute force attack of password guessing.

And also by using hash values of the password for storage.This one basically slows down the process attacks. 


Protecting the authentication tickets provides shield against attacks such as:

  1. spoofing and impersonation, 
  2. session hijacking,
  3. elevation of privilege.
  • using strong password:  Use attributes such as
  1. Minimum length of password
  2. use alphanumeric characters                   
  • Avoid using persistent cookies on client computers.
  • SQLServer authentication:                                          Syntax:SqlConnection conn = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDBFileName=|DataDirectory|\\Database.mdf;Integrated Security=true;user instance=true;");
  • Using single user authentication across multiple applications: Generally this is need in enterprises so save the time of the employees from authenticating themselves again and again for using different applications .
This is done by means of sharing the authentication tickets across various application. Since we are sharing a single authentication key we need to the authentication ticket to be decrypt by every application sharing it to authenticate the user.So we manually provide the validationKey and decryptionKey values and these values are stored inside the <machineKey> element inside the web.config file.

To manually generate these values for the validationKey and decryptionKey we can use algorithms like RNGCryptoServiceProvider  to generate a cryptographically strong random number.


<machineKey validationKey="Hsbfb636576sahfj\mfhhshnj234235"  
           decryptionKey="shakh7857jkjjco985\fhhegf476343" 
           validation="SHA1" decryption="Auto" />

AUTHORIZATION:


  • The new feature  of ASP.NET framework is user authorization which support the  Role Manager, which is used to manage the user roles in  role store database.
  • This Role manager in tur supports the following :
  •   WindowsTokenRoleProvider for Windows groups
  •   SqlRoleProvider for role stores in the SQL Server databases
  •  AuthorizationStoreRoleProvider for roles in Active Directory Application Mode (ADAM) and XML data stores.
In order to use the Role manage we have to enable. And this is done in our application's Web.config file.
  • Syntax :
 <roleManager enabled="true" />
  • Types of authorizations:
  1. URL authorization: It restricts access to specific files and folders within our application's Uniform Resource Identifier (URI) namespace.
  2. File authorization:Used with Window based form authentication .
  3. Role authorization:  can be used declaratively or programmatically.
  •  Protecting the authorization cookie while using role caching :To protect the authorization cookie you need to encrypt and integrity check it, use SSL to protect the cookie over the wire, and do not persist the cookie on the client. When using role caching securing the roles cookie is of prime importance. This is to stop users modifying the list of roles to which they belong, and to stop intruders from gaining information about the roles used by your application.
  • Role Caching : We can even cache the Roles in cookies this is done in this manner:
       <roleManager enabled="true" 
       cacheRolesInCookie="true" .../>
  • Role authorization :                                                                                                                                                                                                                                                                        <system.web><roleManager enabled="true" /></system.web>

CSS stylesheet to create horizontal navigation bar

Description:
The purpose of this article is to show how a horizontal navigation bar achieved using HTML/CSS without the use of tables, images, Javascript, or any other scripting manipulation. The following example validates according to W3C standards, and is compatible with all modern browsers. 




Html page 
___________________________________________________________________________


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>SOMETHING</title>


<link href="css/Navbar.css" rel="stylesheet" type="text/css" />
</head>


<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" background="Image/Background.jpg">
<table width="100%" border="0" cellpadding="0" cellspacing="0" background="Image/Background.jpg">
<tr>
<td>
<img src="Image/Capture.JPG" width="70%" align="center" height="150" />
</td>
</tr>
<tr>
<td>
<div id="navbar" style="margin-top:10px;margin-bottom:20px">
<ul>
<li><a href ="CMS.html" title="View home Page">Home</a></li>
<li><a href ="Login.html" title="Go to Login page">Login</a></li>
<li><a href ="register.html" title="Register Yourself">Register</a></li>
<li><a href ="Help.html" onmouseover="Show()" onmouseout="Hide()">Help</a></li>
<li><a href ="Contact.html" title="Contact technical support">Contact</a></li>
<li><a href ="FAQ.html" title="View Frequently asked questions">FAQ</a></li>
</ul>
</div>
</td>
</tr>
<tr>
<td>
<div id="welcome" style="widht:100%">
<div style="border: 1px solid gray; margin-top: 20pt; margin-bottom: 10pt; width:100%">


<div id="register" style="width:60%">
<div style="border: 1px solid gray; margin-top: 20pt; margin-bottom: 10pt">
<ul>
<font color="#0066CC"><u>Registeration</u> </font>
<li>
Every participant in a conference served by this site,must maintain a single PIN and password. The same PIN must be used forall conferences
</li>
<li>
Follow the link <a href="Register.html">Register</a>
</li>
</ul>
</div>
</div>
</td>
</tr>
</br>
</br>
<tr align="center" height="100">
<td>
<div id="copyright" style="background-color:#000;width:100%">
<div style="border=1px solid gray; margin-top:170px">
<ul>
<font color="#00FFFF"><b>Copyright </b></font>
</ul>
</div>
</div>
</td>
</tr>
</body>
</html>
------------------------------------------------------------------------------------------------------------
navbar.css
_________________________________________________________________________________




@charset "utf-8";
#navbar {
}
#navbar ul {
        margin: 0;
        padding: 5px;
        list-style-type: none;
        text-align: center;
        background-color:#039;
        }


#navbar ul li {
        display:inline;
        }


#navbar ul li a {
        text-decoration: none;
        padding: .2em 1em;
        color: #fff;
        background-color:#039;
        }


#navbar ul li a:hover {
        color: #000;
        background-color: #fff;
        }
#navbar ul li a#onlink:hover{
background:#FFF;
color:#FFF;
text-shadow:1px 1px 1px #000;
}
#navbar {
}


Breaking down the CSS 



  • As with most modern navigation bars, this code is based on the unordered list (<ul>) tag. This makes semantic sense, a navigation bar is really nothing but a list of links leading into your site. The traditional horizontal orientation is simply a convenient means to get all of our most important list items “above the fold,” so the user can see them without having to scroll down the page.
<div id="navbar" style="margin-top:10px;margin-bottom:20px">
<ul>
<li><a href ="CMS.html" title="View home Page">Home</a></li>
<li><a href ="Login.html" title="Go to Login page">Login</a></li>
<li><a href ="register.html" title="Register Yourself">Register</a></li>
<li><a href ="Help.html" onmouseover="Show()" onmouseout="Hide()">Help</a></li>
<li><a href ="Contact.html" title="Contact technical support">Contact</a></li>
<li><a href ="FAQ.html" title="View Frequently asked questions">FAQ</a></li>
</ul>
</div>
  • Making It Horizontal:



#navbar ul li {
        display:inline;
        }

File upload to MyphpAdmin database


<?php
mysql_connect("localhost","","");
mysql_select_db("myconf") or die( "Unable to select database");

if ((($_FILES["file"]["type"] == "application/pdf"))
&& ($_FILES["file"]["size"] < 200000))
  {
  if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    }
  else
    {
    echo "Upload: " . $_FILES["file"]["name"] . "<br />";
    echo "Type: " . $_FILES["file"]["type"] . "<br />";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";

    if (file_exists("upload/" . $_FILES["file"]["name"]))
      {
      echo $_FILES["file"]["name"] . " already exists. ";
      }
    else
      {
      move_uploaded_file($_FILES["file"]["tmp_name"],
      "upload/" . $_FILES["file"]["name"]);
      echo "Stored in: " . "PDF/" . $_FILES["file"]["name"];
      }
    }
  }
else
  {
  echo "Invalid file";
  }

$order="INSERT INTO submission(author,title,type,file,submissionDate,email,discipline)
VALUES ('$_POST[author]','$_POST[title]','$_POST[type]','$_POST[file]',SYSDATE(),'$_POST[email]','$_POST[discipline]')";


if(mysql_query($order))
{
echo "Submission Succeeded";
}
else
{
echo("Submission failed");
}
?>

Time Machine: Time Machine: Use of package in java program

Time Machine: Time Machine: Use of package in java program: Time Machine: Use of package in java program : "Package statement defines a name space in which classes are stored. package cuboid3; cl...